I'm trying to come up with a clean way of sorting a set of strings based on a "sorting template". I apologize if my wording is confusing, but I can't think of a better way to describe it (maybe someone can come up with a better way to describe it after reading what I'm trying to do?).
Consider the following list of strings (my "sort template", each item in the list a "command"):
- [FA, TY, AK, PO, PR, ZZ, QW, BC]
I'd like to use the order of the strings within that list to sort a list of those commands. For example, I'd like the following list:
- [TY, PR, PR, ZZ, BC, AK]
to be sorted into the following list based on the "sorting template":
- [TY, AK, PR, PR, ZZ, BC]
What would be a good way to acomplish this? The best idea I have yet is to use an enumeration...
enum Command
{
FA,
TY,
AK,
PO,
PR,
ZZ,
QW,
BC
};
...and do an Enum.Parse() on each command in my list I want sorted, converting that list from a list of strings into a list of Commands, which would then be sorted based on the order of the enumeration.
I don't know. The enumeration seems like it would work, but is there a better way I could go about this?