Answer the question
In order to leave comments, you need to log in
What data type to use?
It sorts by number normally, and then sorting by letter is needed if the number is the same.
I use char clas[15];
for (int i = 0; i < count; i++)
for (int j = 0; j < count; j++)
if (ob[i].clas[0] < ob[j].clas[0]) {
tem = ob[i];
ob[i] = ob[j];
ob[j] = tem;
}
Answer the question
In order to leave comments, you need to log in
Compare further third characters in strings if the first ones match.
Or compare strings with strcmp.
for (int i = 0; i < count; i++)
if (ob[i].clas[0] < ob[j].clas[0]) {
tem = ob[i];
ob[i] = ob[j];
ob[j] = tem;
for (int i = 0; i < count; i++)
if (ob[i].clas[0] < ob[j].clas[0]) {
tem = ob[i];
ob[i] = ob[j];
ob[j] = tem;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question