delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2005/06/09/07:32:21

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "badri" <yatindran AT gmail DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: 2d array sorting using qsort
Date: 9 Jun 2005 00:00:50 -0700
Organization: http://groups.google.com
Lines: 41
Message-ID: <1118300450.725353.51160@g49g2000cwa.googlegroups.com>
NNTP-Posting-Host: 220.226.49.218
Mime-Version: 1.0
X-Trace: posting.google.com 1118300456 16092 127.0.0.1 (9 Jun 2005 07:00:56 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: Thu, 9 Jun 2005 07:00:56 +0000 (UTC)
User-Agent: G2/0.2
Complaints-To: groups-abuse AT google DOT com
Injection-Info: g49g2000cwa.googlegroups.com; posting-host=220.226.49.218;
posting-account=wIeRGQwAAADXSoYgem15yVGmKqblSpYC
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

hai
this is my 2d array.
int a[][6] = {
			{5,2,20,1,30,10},
			{23,15,7,9,11,3},
			{40,50,34,24,14,4},
			{9,10,11,12,13,14},
			{31,4,18,8,27,17},
			{44,32,13,19,41,19},
			{1,2,3,4,5,6},
			{80,37,47,18,21,9}
		  };
after
for(i=0;i<box;i++)
qsort(a[i],dim,sizeof(int),dim_sort);
int dim_sort(const void *a,const void *b)
{
return ( *(int*)a - *(int*)b);
}
where dim=6, i get the foll o/p:
1 2 5 10 20 30
3 7 9 11 15 23
4 14 24 34 40 50
9 10 11 12 13 14
4 8 17 18 27 31
13 19 19 32 41 44
1 2 3 4 5 6
9 18 21 37 47 80
(works fine!)
now i want to sort each row of elements for above array,
like
1 2 3 4 5 6
1 2 5 10 20 30
...
etc.

what is the qsort routine and function, can anybody help me ?

cheers,
badri

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019