Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!bbn!apple!oliveb!pyramid!jimmy From: jimmy@pyramid.pyramid.com (Jimmy Aitken) Newsgroups: comp.sources.d Subject: Perl help requested Keywords: perl sort Message-ID: <69461@pyramid.pyramid.com> Date: 9 May 89 06:36:38 GMT Reply-To: jimmy@pyramid.pyramid.com (Jimmy Aitken) Organization: Pyramid Technology Corp., Mountain View, CA Lines: 29 Since perl was posted to comp.sources*, I've posted this request here. I couldn't think of a more appropriate newsgroup so here goes. I've got a perl program that requires an array to be sorted ignoring case and non alpha-numeric characters. i.e. The equivalent of 'sort -fd'. Currently I do it by: @sorted=sort fieldsort @list | | sub fieldsort { local($x=$a, $y=$b); $x =~ tr/A-Z/a-z/; $x =~ tr/ -@{-}//; $y =~ tr/A-Z/a-z/; $y =~ tr/ -@{-}//; $x lt $y ? -1 : $x gt $y ? 1 : 0; } To my mind this is ugly and uses about twice the user time comapred to a simple 'sort @list.' Can anyone come up with a cleaner/faster way of doing this operation? Thanks for any help. jimmy -- -m------ Jimmy Aitken ---mmm----- On Loan from: Pyramid Technology Ltd., U.K. -----mmmmm--- To: Pyramid Technology Corp, U.S.A -------mmmmmmm- {uunet, decwrl}!pyramid!jimmy