# I need helo sorting 2 dimention arrays

• 04-27-2011
Iron Hide
I need helo sorting 2 dimention arrays
Hi,
I was working on sorting 2 dimension arrays in ascending order and need a little help.
Here is my code:

Code:

``` #include <stdio.h> void bubbleSort(int [][]); void swap(int *,int *); int main() { int i; char list[5][9] = {"tulip","marigold","petunia","rose","daisy"}; for(i=0;i<5;i++) { printf("\n%10s", *(list + i) ); } printf("\n\n"); return 0; } void bubbleSort(int list[][])) {         int current,walker;                         for(current=0;current<MAX;current++){                 for(walker=MAX-1;walker > current;walker--) {                                             if (list[walker] < list[walker-1]) {                           swap(&list[walker],&list[walker-1]); //swap                         }                 }         } } void swap(int *val1,int *val2) {         int temp;         temp = *val1;            *val1 = *val2;         *val2 = temp;    }```
can someone please help me with that? I am also suspecting the use of strcmp() and and strcpy() to copy one string to another, but now sure how.

Thanks
• 04-27-2011
cas
Code:

`void bubbleSort(int [][]);`
You have to give all dimensions but the first, so:
Code:

`void bubbleSort(int [][ENTRY_SIZE]);`
But... you've got an array of strings you're trying to sort, not an array of an array of ints. It looks like you took code to sort an array of ints, slapped in an array of strings, and expected it to work. You have to rewrite the sort function to expect such an array; the compare part to compare strings; and the swap part to swap strings.

Plus you'll actually have to call your sort function for it to sort anything.

Edit: I missed your comment about strcmp() and strcpy(). Do you know how these functions work? If not, consult your C book and get familiar with them before attempting a sort.