In attempting to use the existing Alphabetic sort type to sort UIGrid / UITable lists to sort numeric entries, it does not seem to always reliably sort correctly. I had originally thought that the Alphabetic sort would work for numeric, but that does not seem to be the case. I've coded up a quick fix however that allows Smallest to Largest numeric sort:
In UITable.cs, line 26, change the enum to have a Numeric option:
public enum Sorting
{
None,
Alphabetic,
Horizontal,
Vertical,
Custom,
Numeric // Add this
}
Still in UITable.cs, around line 128, add the following inside the "if (sorting != Sorting.none)" block:
else if (sorting == Sorting.Numeric) list.Sort(UIGrid.SortNumeric);
In UIGrid.cs, at the top where the Enum is for Sorting, add the Numeric option here as well:
public enum Sorting
{
None,
Alphabetic,
Horizontal,
Vertical,
Custom,
Numeric
}
Finally, in UIGrid.cs, add the following around line 280, where the other sort methods exist:
static public int SortNumeric (Transform a, Transform b) { return System.Convert.ToInt32(a.name).CompareTo(System.Convert.ToInt32(b.name)); }
That's it! Now your numeric entries will for certain sort properly when you call Reposition. Hope it helps!