My sort function is working but it doesnt match the exact way the matrix checker sorts.

my function sorts correctly by population size but when two values equal the same it puts the p5e postal code above the E7C postal code. Is there a way i can fix this so it shifts the postal code by just checking the population values? I used selection sort to sort the array
13 Replies
Revan
Revan2y ago
Revan
Revan2y ago
is the only soloution is to create a sorting function that matches whatever the matrix programmed? Cause what I came up with is just manually see which postal codes of the same population sizes need to be switched.
sigma
sigma2y ago
where do you get this list of values? from a file?
Revan
Revan2y ago
yeah a csv file
Σ
Σ2y ago
You can just sort with 2 values
Revan
Revan2y ago
how would i do that like just selection sort again but the size is 2?
sigma
sigma2y ago
In your sorting function, you can handle the case when the population values are the same, to decide the sorting by the postal code
Σ
Σ2y ago
Yep that
Revan
Revan2y ago
Is there a way to sort the whole postal code ? Cause with my knowledge I have to sort by the first letter and if that’s a match I have to sort by the second element and if that’s a match then I have to sort by the third element of the postal code
sigma
sigma2y ago
I think there's a cstring function that can help. Let me look for it https://cplusplus.com/reference/cstring/strcmp/
Revan
Revan2y ago
Tyty I remember this from IPC ok this DIY suddenly became more doable lol
sesame.seed2
sesame.seed22y ago
how did you fix this error with matrix
Revan
Revan2y ago
I used the strcmp for the postal code And then swamped with which ever postal code was higher