Created
September 15, 2017 10:15
-
-
Save bsmaat/00f6b5ef1a65dde21503f7bd6237c183 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Alphabet | |
{ | |
A, | |
B, | |
C, | |
D, | |
E, | |
F, | |
G | |
} | |
public class MyClass | |
{ | |
public Alphabet Alpha | |
{ | |
get; | |
set; | |
} | |
public MyClass(Alphabet alpha) { | |
Alpha = alpha; | |
} | |
} | |
public class Prorgam | |
{ | |
public List<MyClass> ListToSort = new List<MyClass>(); | |
public List<Alphabet> EnumsToSortBy = new List<Alphabet>() { Alphabet.A, Alphabet.C, Alphabet.E}; | |
public static void Main(string[] args) | |
{ | |
// Fill ListToSort.. | |
ListToSort.Add(new Myclass(Alphabet.A)); | |
ListToSort.Add(new Myclass(Alphabet.B)); | |
ListToSort.Add(new Myclass(Alphabet.C)); | |
ListToSort.Add(new Myclass(Alphabet.D)); | |
ListToSort.Add(new Myclass(Alphabet.E)); | |
ListToSort.Add(new Myclass(Alphabet.F)); | |
ListToSort.Add(new Myclass(Alphabet.G)); | |
ListToSort.SortingMethod(EnumsToSortBy); | |
// now ListToSort is in order, like this: | |
/* | |
ListToSort[0] is MyClass with Alpha = Alphabet.A | |
ListToSort[1] is MyClass with Alpha = Alphabet.C | |
ListToSort[2] is Myclass with Alpha = Alphabet.E | |
ListToSort[3...6] Is MyClass with Alpha = the rest of the enum values (not fussed about order right now) | |
*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment