how to sort the string according to the integer values