private int OneCompare(ValueTreeRow x, ValueTreeRow y, ValueTreeSortRule Rule) { IValue xValue = x.Get(Rule.Column); IValue yValue = y.Get(Rule.Column); int result = _comparer.Compare(xValue, yValue) * Rule.direction; return(result); }
private List <ValueTreeSortRule> GetSortRules(string Columns) { string[] a_columns = Columns.Split(','); List <ValueTreeSortRule> Rules = new List <ValueTreeSortRule>(); foreach (string column in a_columns) { string[] description = column.Trim().Split(' '); if (description.Count() == 0) { throw RuntimeException.PropNotFoundException(""); // TODO: WrongColumnNameException } ValueTreeSortRule Desc = new ValueTreeSortRule(); Desc.Column = this.Columns.FindColumnByName(description[0]); if (Desc.Column == null) { throw RuntimeException.PropNotFoundException(description[0]); } if (description.Count() > 1) { if (String.Compare(description[1], "DESC", true) == 0 || String.Compare(description[1], "УБЫВ", true) == 0) { Desc.direction = -1; } else { Desc.direction = 1; } } else { Desc.direction = 1; } Rules.Add(Desc); } return(Rules); }