Skip to content

Instantly share code, notes, and snippets.

@skalinets
Created October 6, 2011 09:38
Show Gist options
  • Save skalinets/1266968 to your computer and use it in GitHub Desktop.
Save skalinets/1266968 to your computer and use it in GitHub Desktop.
public void Sort(List<Person> data)
{
Person tmp = null;
for(int i = 0; i<data.Count; i++)
{
for(int j = i; j<data.Count; j++)
{
if(data[j].Compare(data[i]))
{
tmp = data[j];
data[j] = data[i];
data[i] = tmp;
}
}
}
}
...
public bool Compare(Person target)
{
bool result = false;
if(target.Age < this.Age)
{
result = true;
}
else if(target.Age == this.Age)
{
if(String.Compare(this.Name, target.Name, false) > 0)
{
result = true;
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment