private IEnumerable<ShareListViewModel> Sort(IEnumerable<ShareListViewModel> collection, string sortBy, ListSortDirection direction)
{
var list = new List<ShareListViewModel>(collection);
if (sortBy == LanguagesManager.Instance.ShareControl_Name)
{
list.Sort((x, y) =>
{
int c = x.Name.CompareTo(y.Name);
if (c != 0) return c;
c = x.Path.CompareTo(y.Path);
if (c != 0) return c;
return 0;
});
}
else if (sortBy == LanguagesManager.Instance.ShareControl_Path)
{
list.Sort((x, y) =>
{
int c = x.Path.CompareTo(y.Path);
if (c != 0) return c;
return 0;
});
}
else if (sortBy == LanguagesManager.Instance.ShareControl_BlockCount)
{
list.Sort((x, y) =>
{
int c = x.BlockCount.CompareTo(y.BlockCount);
if (c != 0) return c;
c = x.Path.CompareTo(y.Path);
if (c != 0) return c;
return 0;
});
}
if (direction == ListSortDirection.Descending)
{
list.Reverse();
}
return list;
}