[SOLVED] Sort not working
Posted: Sun Dec 13, 2015 9:21 pm
The following code is working in simulator but not in browser:
Helper Class
Sort code
BUG
first is 'B', but it should be 'A'. Works fine in simulator
Helper Class
Code: Select all
public class SitebarItem : IComparable<SitebarItem>
{
public string Text { get; set; }
public object Tag { get; set; }
public SitebarItem()
{
Text = "";
}
public SitebarItem(string text, object tag)
{
Text = text;
Tag = tag;
}
public int CompareTo(SitebarItem other)
{
return Text.CompareTo(other.Text);
}
}
Sort code
Code: Select all
List<SitebarItem> test = new List<SitebarItem>();
test.Add(new SitebarItem("B", "B"));
test.Add(new SitebarItem("A", "A"));
test.Sort();
string first = test[0].Text;
BUG
first is 'B', but it should be 'A'. Works fine in simulator