J
jpoloney
I was wondering if there was a quick and easy way to sort multiple
arrays in C++. What I mean is that, say I have 3 integer arrays. They
are in order by array indices (array1[0] corresponds to array2[0] and
array3[0], etc). I want to do something exactly like the Excel sort of
"Sort by A, then by B, then by C". Meaning, sort array A in ascending
order, then inside of that sort B in ascending order, etc. Here is some
pseudo code for what I'm trying to do:
array1 = [1, 1, 2, 2, 3, 3];
array2 = [2, 1, 2, 1, 2, 1];
array3 = [1, 2, 3, 4, 5, 6];
sort_1_then_2_then_3();
array1 = [1, 1, 2, 2, 3, 3];
array2 = [1, 2, 1, 2, 1, 2];
array3 = [2, 1, 4, 3, 6, 5];
Is there anyway to do this using STL sorts in C++ or would I have to
write this algorithm from scratch?
arrays in C++. What I mean is that, say I have 3 integer arrays. They
are in order by array indices (array1[0] corresponds to array2[0] and
array3[0], etc). I want to do something exactly like the Excel sort of
"Sort by A, then by B, then by C". Meaning, sort array A in ascending
order, then inside of that sort B in ascending order, etc. Here is some
pseudo code for what I'm trying to do:
array1 = [1, 1, 2, 2, 3, 3];
array2 = [2, 1, 2, 1, 2, 1];
array3 = [1, 2, 3, 4, 5, 6];
sort_1_then_2_then_3();
array1 = [1, 1, 2, 2, 3, 3];
array2 = [1, 2, 1, 2, 1, 2];
array3 = [2, 1, 4, 3, 6, 5];
Is there anyway to do this using STL sorts in C++ or would I have to
write this algorithm from scratch?