From: sproctor AT enter DOT net (Sean Proctor) Newsgroups: comp.os.msdos.djgpp Subject: Re: Need help on integer array sorting!! Date: Wed, 04 Aug 1999 22:27:54 GMT Message-ID: <37a9bc77.3501210@news.enter.net> References: <19990804124158 DOT 17239 DOT 00001341 AT ng-cs1 DOT aol DOT com> X-Newsreader: Forte Agent 1.5/32.452 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 207.16.154.128 X-Original-NNTP-Posting-Host: 207.16.154.128 X-Trace: 4 Aug 1999 18:28:34 -0400, 207.16.154.128 Organization: Enter.Net Lines: 29 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On 04 Aug 1999 16:41:58 GMT, orvbongat AT aol DOT com (Orvbongat) wrote: >Hi, anyone who can send me a source or a place to get a source code >or a C integer sorting routine or if you have one, please send it to > >orvbongat AT aol DOT com > >thanks There's a lot of different ways... The simplest would probably be to compare your first two, switch if the first is larger, etc. #define SIZE 50 int array[SIZE], i, j; for(i = 0; i < SIZE; i++) printf("%i", array[i]); for(i = 0; i < SIZE - 1; i++) { for(j = 0; j < SIZE - i; j++) { if(array[j] > array[j + 1]) swap(array[j], array[j + 1]); } } That should work. The swap function is obvious. Sean