bdpq sorting