How to sort char array Z-A...

This is my code for sort char array...how to sort Z-A
I use 2d char array named nazivi...

for (int i=0;i<br_unesenih_el;i++)
for(int j=i;j<=br_unesenih_el;j++)
if((strcmp(nazivi[j],nazivi[i]))>0)
{
strcpy(temp,nazivi[i]);
strcpy(nazivi[i],nazivi[j]);
strcpy(nazivi[j],temp);

/*pomocna = polje_cijena[i];
polje_cijena[i]=polje_cijena[j];
polje_cijena[j]=pomocna;

pomocna2 = polje_sifra[i];
polje_sifra[i]=polje_sifra[j];
polje_sifra[j]=pomocna2;*/
}
Last edited on
Please help :(
Add comments (English only) into your snippet code.
Also you should put your snippet code into <> format tag.
How can i do this?
1- Sort all characters in an array or multiple arrays?
2-
br_un... -> len
nazivi -> str

Agree?
char nazivi[1000][20] -> user writes names in this array....
br_un... -> number of names....

With this code i can sort A-Z...How can i change this code to sort Z-A?
Please help...

This strange algorithm is harder than I and (you thought).
You only need the first character of all names to be sorted, or all perfectly??

You should have a multiple layered checking loops, per loop range : 1 character, and counting.
Maybe I'll provide an example later but you should follow this advice and try thinking yourself... :)

Good Luck!!!
Last edited on
Do you know simply example code for this?
I need all all perfectly....

example... user input jackson, arny and bony...and program print jackson, bony, arny

I need just this part of code change (or some better example)
Last edited on
Topic archived. No new replies allowed.