From 69dba1a231c241dc8a24a1652948c921755df6de Mon Sep 17 00:00:00 2001 From: Anandh-SF4665 Date: Wed, 3 Sep 2025 17:27:41 +0530 Subject: [PATCH] Updated README.md file --- README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/README.md b/README.md index af63b7b..3509f74 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,69 @@ # 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; + } +} +```