Correctly sort taks by quality density