Functional (I think) sortify