Sorting function was implemented.