B
Bob Dankert
Is there any way to maintain the sort order of a sort on a 2D array? For
example:
I have the array:
1,a 2,a 3,f 4,a 5,s 6,a 7,z 8,b
and sort it by the second column, and I get:
4,a 6,a 1,a 2,a 8,b 3,f 5,s 7,z
The results I am looking for would be like:
1,a 2,a 4,a 6,a 8,b 3,f 5,s 7,z
I would like the sort to keep in mind the initial sorting, so the final
result has sorting done on two rows (similar to sorting by multiple columns
in a database, or by clicking to sort a windows explorer window first by one
column, then by another).
The code I use for sorting is very basic:
public class comp : IComparer
{
int column;
public comp(int col)
{
column = col;
}
public int Compare(object x, object y)
{
return
objectCompare.Compare(((Array)x).GetValue(column),((Array)y).GetValue(column
));
}
}
I know that my custom listview which allows for sorting by multiple columns
(implemented based on Microsoft's implementation) will work as I am looking
for, so I hope that this is something that I will somewhat-easily be able to
accomplish.
I appreciate any thoughts, help, and suggestions!
Thanks,
Bob Dankert
example:
I have the array:
1,a 2,a 3,f 4,a 5,s 6,a 7,z 8,b
and sort it by the second column, and I get:
4,a 6,a 1,a 2,a 8,b 3,f 5,s 7,z
The results I am looking for would be like:
1,a 2,a 4,a 6,a 8,b 3,f 5,s 7,z
I would like the sort to keep in mind the initial sorting, so the final
result has sorting done on two rows (similar to sorting by multiple columns
in a database, or by clicking to sort a windows explorer window first by one
column, then by another).
The code I use for sorting is very basic:
public class comp : IComparer
{
int column;
public comp(int col)
{
column = col;
}
public int Compare(object x, object y)
{
return
objectCompare.Compare(((Array)x).GetValue(column),((Array)y).GetValue(column
));
}
}
I know that my custom listview which allows for sorting by multiple columns
(implemented based on Microsoft's implementation) will work as I am looking
for, so I hope that this is something that I will somewhat-easily be able to
accomplish.
I appreciate any thoughts, help, and suggestions!
Thanks,
Bob Dankert