I need in C# to sort some distances in some objects which are in float. I use delegate and Array.Sort to sort them but it seems that I can’t use float.
How can I keep the precision of those float when converting to int?
Is it possible to use Array.Sort with float instead of int in return?
Without using LINQ.
Array.Sort<T>(T[] array, Comparison<T> comparison)is not restricted to any type as long as you provide correct comparison delegate. Comparison delegate should return integer value containing the result of compare operation, not a value to be compared with something. For example, if you have classXwithfloatpropertyProperty, you can sort them like this: