SortByValue function to sort object by values