Sorting function added.