Added a simple sort function that is working on a index set.