Q:

Unity3d rearrange a string

Say you have a string 5/9/2010 and you want to rearrange it to read 2010/5/9. How would you go about doing that?
I want to sort a list by a string that happens to be a date. While I could make it into a date, I want to stick with a string, if possible because the time part of the datetime is hard to eliminate. (This is being used in an sqlite database for a Unity3d App.)
Forgive me if this is a duplicate.

A:

If you can guarantee that the string will always be the same input format, you can split the string on the /:
    string input = "5/9/2010";
    string[] inputSections = input.Split('/');
    string output = string.Format("{0}/{1}/{2}", inputSections[2], inputSections[0], inputSections[1]);

Working Fiddle
My code is very verbose, you can certainly simplify it for your needs.  I would also utilize the string inerpolation feature of C# 6 if it is available to you:
    string input = "5/9/2010";
    string[] inputSections = input.Split('/');
    string output = $"{inputSections[2]}/{inputSections[1]}/{inputSections[0]}";

