Fix code to sort groups in descending order