GrapeCity.Windows.SpreadSheet.Data Namespace > SortInfo Class > SortInfo Constructor : SortInfo Constructor(Int32,Boolean,IComparer) |
true
, sort order is ascending.
'Declaration Public Function New( _ ByVal index As System.Integer, _ ByVal ascending As System.Boolean, _ ByVal comparer As System.Collections.IComparer _ )
'Usage Dim index As System.Integer Dim ascending As System.Boolean Dim comparer As System.Collections.IComparer Dim instance As New SortInfo(index, ascending, comparer)
true
, sort order is ascending.public class CustomSortComparer : IComparer { public int Compare(object x, object y) { double xConvert = Convert.ToDouble(x.ToString()); double yConvert = Convert.ToDouble(y.ToString()); return Convert.ToInt32(xConvert - yConvert); } } gcSpreadSheet1.Sheets[0].SetText(0, 0, "1"); gcSpreadSheet1.Sheets[0].SetText(1, 0, "10"); gcSpreadSheet1.Sheets[0].SetText(2, 0, "2"); gcSpreadSheet1.Sheets[0].SetText(3, 0, "20"); gcSpreadSheet1.Sheets[0].SetText(4, 0, "3"); gcSpreadSheet1.Sheets[0].SetText(5, 0, "30"); gcSpreadSheet1.Sheets[0].SortRange(0, 0, 6, 1, true, new SortInfo[] { new SortInfo(0, false,new CustomSortComparer()) }); gcSpreadSheet1.Invalidate();
Public Class CustomSortComparer Implements IComparer Public Function Compare(x As Object, y As Object) As Integer Implements IComparer.Compare Dim xConvert As Double = Convert.ToDouble(x.ToString()) Dim yConvert As Double = Convert.ToDouble(y.ToString()) Return Convert.ToInt32(xConvert - yConvert) End Function End Class GcSpreadSheet1.Sheets(0).SetText(0, 0, "1") GcSpreadSheet1.Sheets(0).SetText(1, 0, "10") GcSpreadSheet1.Sheets(0).SetText(2, 0, "2") GcSpreadSheet1.Sheets(0).SetText(3, 0, "20") GcSpreadSheet1.Sheets(0).SetText(4, 0, "3") GcSpreadSheet1.Sheets(0).SetText(5, 0, "30") GcSpreadSheet1.Sheets(0).SortRange(0, 0, 6, 1, True, New SortInfo() {New SortInfo(0, False, New CustomSortComparer())}) GcSpreadSheet1.Invalidate()
Target Platforms: Windows 7, Windows 8 Desktop, Windows Vista SP1 or later, Windows Server 2000, Windows 2000 Professional (SP4), Windows XP (SP2), Windows 2008, Windows 2003 Server (SP1)