Added code to sort data
Ight. This things fully functional now