added sorting function, sort the data list before return the list