Updated method sortBy -- unfinished