944,192 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 5842
  • C RSS
May 16th, 2006
0

How to Sort a MultiDimensional Array

Expand Post »
How to Sort a MultiDimensional Array in C ????
in ascending order ?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
breal is offline Offline
4 posts
since Apr 2006
May 16th, 2006
0

Re: How to Sort a MultiDimensional Array

how many dimensions are we talking about?

two? thwee?
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
May 16th, 2006
0

Re: How to Sort a MultiDimensional Array

Have you figured out how to sort a 1-D array using your own comparison function, and the standard library qsort() function?

It's exactly the same method, the only trick is getting the compare function declared properly.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
May 16th, 2006
0

Re: How to Sort a MultiDimensional Array

Quote originally posted by breal ...
How to Sort a MultiDimensional Array in C ????
in ascending order ?
If your are trying to sort a MultiDimensional array of character you can see this. this is simple bubble sort
  1. #define SIZE 100
  2. void Sort(char arr[SIZE][SIZE], int NoOfRows) {
  3. int i=0,j=0 ;
  4. char temp[SIZE] ;
  5. for(i=0;i<NoOfRows;++i) {
  6. for(j=0;j<NoOfRows;++j) {
  7. if(0 > strcmp(arr[i],arr[j])) {
  8. strcpy(temp,arr[j]) ;
  9. strcpy(arr[j],arr[i]) ;
  10. strcpy(arr[i],temp) ;
  11. }
  12. }
  13. }
  14. return ;
  15. }
Reputation Points: 39
Solved Threads: 24
Junior Poster
dubeyprateek is offline Offline
176 posts
since Mar 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Don't know where to begon
Next Thread in C Forum Timeline: Hi guys. Need some help here please





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC