tbf/Results/Forms/LviIntColumnComparer.cs
2021-11-13 05:38:10 +01:00

33 lines
843 B
C#

using System;
using System.Collections;
using System.Windows.Forms;
using Common;
namespace Results.Forms
{
public class LviIntColumnComparer : IComparer
{
int column;
MySortOrder order;
public LviIntColumnComparer()
{
column = 0;
order = MySortOrder.Ascending;
}
public LviIntColumnComparer(int column, MySortOrder order)
{
this.column = column;
this.order = order;
}
public int Compare(object x, object y)
{
int valX = int.Parse(((ListViewItem)x).SubItems[column].Text);
int valY = int.Parse(((ListViewItem)y).SubItems[column].Text);
return (order == MySortOrder.Descending || order == MySortOrder.Descending2) ? (valY - valX) : (valX - valY);
}
}
}