so I put the number and alphabet into an array and a string but they are related as in 10b must be 10b and 4b must be 4b.
I am hoping to sort the string with the number alphabetically from a to b to c... etc
The number with the ASCII odd alphabet should be in ascending order but the number with the ASCII even alphabet should be in descending order.
i.e. as the following case should be 5a 12a 10b 4b 4h
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main(int argc, char *argv[]) {
char *alpha[] = {"b", "b", "h", "a", "a"};
int num[5]= {4,10,4,12, 5};
int i;
printf("The classes are ");
for (i=0; i<5; i++){
printf("%d%s ", num[i], alpha[i]);
}
printf("\n");
printf("The classes are rearragnged to:");
return 0;
}
Any idea on how should I sort them?
(Extra note: I tried bubble sort but doesn't really work with an array and string... I also put them both in a string as well but when sorting with 4b and 10b, it goes random as it cant compare the correct string position with a single digit with double digit...)
1a 2a 3a 4a 1b 3b==>1a 3a 4a 2a 1b 3b?