@@ -5,28 +5,38 @@ namespace Rubberduck.UI
55{
66 public class GridViewSort < T >
77 {
8- private bool _sortedAscending ;
9- private string _columnName ;
8+ public bool SortedAscending { get ; private set ; }
9+ public string ColumnName { get ; private set ; }
1010
1111 public GridViewSort ( string columnName , bool sortedAscending )
1212 {
13- _columnName = columnName ;
14- _sortedAscending = sortedAscending ;
13+ ColumnName = columnName ;
14+ SortedAscending = sortedAscending ;
1515 }
1616
1717 public IEnumerable < T > Sort ( IEnumerable < T > items , string columnName )
1818 {
19- if ( columnName == _columnName && _sortedAscending )
19+ if ( columnName == ColumnName && SortedAscending )
2020 {
21- _sortedAscending = false ;
21+ SortedAscending = false ;
2222 return items . OrderByDescending ( x => x . GetType ( ) . GetProperty ( columnName ) . GetValue ( x ) ) ;
2323 }
2424 else
2525 {
26- _columnName = columnName ;
27- _sortedAscending = true ;
26+ ColumnName = columnName ;
27+ SortedAscending = true ;
2828 return items . OrderBy ( x => x . GetType ( ) . GetProperty ( columnName ) . GetValue ( x ) ) ;
2929 }
3030 }
31+
32+ public IEnumerable < T > Sort ( IEnumerable < T > items , string columnName , bool sortAscending )
33+ {
34+ SortedAscending = sortAscending ;
35+ ColumnName = columnName ;
36+
37+ return sortAscending
38+ ? items . OrderBy ( x => x . GetType ( ) . GetProperty ( columnName ) . GetValue ( x ) )
39+ : items . OrderByDescending ( x => x . GetType ( ) . GetProperty ( columnName ) . GetValue ( x ) ) ;
40+ }
3141 }
3242}
0 commit comments