An open API service indexing awesome lists of open source software.

https://github.com/syncfusionexamples/xamarin-forms-listview-custom-sorting

This example shows how to perform sorting using custom comparer in XForms ListView control.
https://github.com/syncfusionexamples/xamarin-forms-listview-custom-sorting

custom-sorting sorting xamarin xamarin-listview

Last synced: 3 months ago
JSON representation

This example shows how to perform sorting using custom comparer in XForms ListView control.

Awesome Lists containing this project

README

          

# xamarin-forms-listview-custom-sorting
Xamarin Forms ListView provides support to custom sort the items using Comparer.

## Sample

```xaml



















. . .
. . .




CustomSortComparer:
public class CustomSortComparer : IComparer
{
public int Compare(object x, object y)
{
if (x.GetType() == typeof(ListViewContactsInfo))
{
var xitem = (x as ListViewContactsInfo).ContactName;
var yitem = (y as ListViewContactsInfo).ContactName;

if (xitem.Length > yitem.Length)
{
return 1;
}
else if (xitem.Length < yitem.Length)
{
return -1;
}
else
{
if (string.Compare(xitem, yitem) == -1)
return -1;
else if (string.Compare(xitem, yitem) == 1)
return 1;
}
}

return 0;
}
}
```