Input String may look like this :
"2 4 8 6" or "a b z g h"
Output String should look like this:
"2 4 6 8" and "a b g h z"
I'm trying to find an answer using C# LINQ and any other simple methods will be fine. As a beginner I went through this question in this link : Is there a simple way that I can sort characters in a string in alphabetical order
However, I'm unable to sort the array properly in the order I wish it to be.
Edit : Please note that number of spaces in between the characters will be 1. If possible please consider this test case "2 15 3" as well.
"123 abc 8 + 1 xyz 4 9 -5"
what is the output string? – Dmitry Bychenko Feb 27 '17 at 11:01string result = string.Join(" ", source.Split(' ').OrderBy(x => x));
We split the initial string, sort the substrings and then combine them back to the string – Dmitry Bychenko Feb 27 '17 at 11:06