string strArr="5,3,8,1,9,2,0,6,4,7";
I would like to rearrange the order of the numbers so the result will look like the following:
string result ="0,1,2,3,4,5,6,7,8,9";
Any idea?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Split, sort and join:
Or:
If you have a string with larger numbers that need to be sorted numerically, you can’t sort them as strings, as for example “2” > “1000”. You would convert each substring to a number, sort, and then convert them back:
Or, as mastoj suggested, parse the strings in the sorting: