working on sort function