Implemented generallity sorting