diff --git a/reflect/Metadata/Tables.cs b/reflect/Metadata/Tables.cs index d78700f9..6f3bdcfa 100644 --- a/reflect/Metadata/Tables.cs +++ b/reflect/Metadata/Tables.cs @@ -425,7 +425,7 @@ namespace IKVM.Reflection.Metadata } } - abstract class SortedTable : Table, IComparer + abstract class SortedTable : Table where T : SortedTable.IRecord { internal interface IRecord @@ -537,25 +537,19 @@ namespace IKVM.Reflection.Metadata protected void Sort() { - int[] map = new int[rowCount]; - for (int i = 0; i < map.Length; i++) + ulong[] map = new ulong[rowCount]; + for (uint i = 0; i < map.Length; i++) { - map[i] = i; + map[i] = ((ulong)records[i].SortKey << 32) | i; } - Array.Sort(map, this); + Array.Sort(map); T[] newRecords = new T[rowCount]; for (int i = 0; i < map.Length; i++) { - newRecords[i] = records[map[i]]; + newRecords[i] = records[(int)map[i]]; } records = newRecords; } - - int IComparer.Compare(int x, int y) - { - int rc = records[x].SortKey.CompareTo(records[y].SortKey); - return rc == 0 ? x.CompareTo(y) : rc; - } } sealed class ModuleTable : Table