WIP: make sort a function, not a method