Sorted functionality added