how to sort a 2d array of strings alphabetically in c

how to sort a 2d array of strings alphabetically in c?

I assume that you mean an array of strings by “2d array of strings”.
In that case, use string compare function “strcmp()” in the place of ‘>’ or ‘<’ sign in your sort function.

1 Like

As @p00r posted use strcmp() for comparison.

This is a link to get a better idea about strcmp()

http://www.cplusplus.com/reference/cstring/strcmp/

But how you want to sort 2D array?

What should be the result for:

String[][] sa = {
    { "A", "C" }
    { "B", "D" }
}

it’s Java syntax, but still should be clear what I meant…