I need a function that converts an array of strings into a string that is sortable in the same order as if you would sort the inputs (sort first input argument, if equal sort second etc...)
In native code, separating the strings with \0 would do, but somehow
("a" + char.MinValue + "2").CompareTo("a1") equals to 1!
What is going on and is it possible to create such a function?
public static string StringsToKey(params string[] values)
EDIT: This is the test I want to succeed:
Assert.IsTrue(MiscUtils.StringsToKey("a", "2").CompareTo(MiscUtils.StringsToKey("a1")) < 0);
I would like to avoid using CompareOrdinal because I'm not always in control of how the key would be sorted. Also, ordinal might yield incorrect sorting order on international sets...