sort according to class