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
RevanOP3y ago
Revan
RevanOP3y 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
sigma3y ago
where do you get this list of values? from a file?
Revan
RevanOP3y ago
yeah a csv file
Σ
Σ3y ago
You can just sort with 2 values
Revan
RevanOP3y ago
how would i do that like just selection sort again but the size is 2?
sigma
sigma3y 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
Σ
Σ3y ago
Yep that
Revan
RevanOP3y 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
sigma3y ago
I think there's a cstring function that can help. Let me look for it https://cplusplus.com/reference/cstring/strcmp/
Revan
RevanOP3y ago
Tyty I remember this from IPC ok this DIY suddenly became more doable lol
sesame.seed2
sesame.seed23y ago
how did you fix this error with matrix
Revan
RevanOP3y ago
I used the strcmp for the postal code And then swamped with which ever postal code was higher
Want results from more Discord servers?
Add your server