1 // 2 // Copyright (c) 2010-2018 Antmicro 3 // Copyright (c) 2011-2015 Realtime Embedded 4 // 5 // This file is licensed under the MIT License. 6 // Full license text is available in 'licenses/MIT.txt'. 7 // 8 using System; 9 10 namespace Antmicro.Renode.Utilities 11 { 12 public abstract class TypeSorter 13 { Sort(Type[] t)14 public static void Sort(Type[] t) 15 { 16 Array.Sort(t, Compare); 17 } 18 Compare(Type tone, Type ttwo)19 public static int Compare(Type tone, Type ttwo) 20 { 21 var t1tot2 = tone.IsAssignableFrom(ttwo); 22 var t2tot1 = ttwo.IsAssignableFrom(tone); 23 24 if(t1tot2 && !t2tot1) 25 { 26 return 1; 27 } 28 else if(t2tot1 && !t1tot2) 29 { 30 return -1; 31 } 32 33 return 0; 34 } 35 } 36 } 37 38