Path: utzoo!yunexus!ists!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: compare strings, strcmp Keywords: strcmp,strings Message-ID: <11643@smoke.BRL.MIL> Date: 19 Nov 89 00:54:00 GMT Article-I.D.: smoke.11643 References: <4463@blake.acs.washington.edu> <11605@smoke.BRL.MIL> <214@isgtec.UUCP> <2742@munnari.oz.au> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 26 In article <2742@munnari.oz.au> ok@mudla.cs.mu.OZ.AU (Richard O'Keefe) writes: >> In article <11605@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >> >Dump it into an external file and invoke the system sort utility on the file. >A general point about questions like this: any answer we give is likely >to be an answer to the wrong question. I find myself wondering why anyone >wants to sort char array[10000][200]. That was the main point that I wanted to call attention to. >There is another extremely important reason why Doug Gwyn's suggestion is >a REALLY good one even if it proves slower in some cases. That is that >the system sort utility provides you with a mini-language for specifying >comparisons which can make it a lot easier to get your sort right. That may or may not be important, depending on the application. One thing one should always try to keep in mind is that for problems like sorting, much effort has already been invested in finding good solutions, and it is likely to be counterproductive to spend one's own limited time reinventing wheels poorly when good wheels are sitting on the shelf. qsort() probably suffices for this case, system("sort ...") for complex key matching requirements (too bad a comparable binary-record sort utility isn't a standard UNIX utility), and if none of the existing tools has the right properties only THEN would one program his own sorting algorithm.