I am trying to sort my observable collection by numbers. I found here on this forum this post: How do I sort an observable collection?
Everything is working fine till the line:
return Utils.LogicalStringCompare(a.Penize, b.Penize);
Where i get this error: "'Utils' is inaccesible due to its protection level."
My code:
static class Extensions
{
public static void Sort<T>(this ObservableCollection<T> collection) where T : IComparable
{
List<T> sorted = collection.OrderBy(num => num).ToList();
for (int i = 0; i < sorted.Count(); i++)
collection.Move(collection.IndexOf(sorted[i]), i);
}
}
public class Uzivatel : IComparable
{
public int CompareTo(object o)
{
Uzivatel a = this;
Uzivatel b = (Uzivatel)o;
return Utils.LogicalStringCompare(a.Penize, b.Penize);
}
public int Penize{get;set;}
}
Can somebody help me with this please ? (Problem is still there even when i set that Extensions class to public.)
I dont want to use this insted, because its badly sorting numbers (1005 < 15 -_-):
return string.Compare(a.Penize.ToString(), b.Penize.ToString());
I will be happy for any help you will give me.