At 11:21 AM +0100 3/2/03, Eelco Alosery wrote:
I want to display a text file alfabetical.
I have this in a text file named groep.file

Installatie matriaal|144548342|
Verlichting|784803956|
Draad en kabel|474860160|
Schakel matriaal|731915587|
Schakel en verdeel inrichtingen|630243268|
Data en coax|4466374|

I want to open this file and read the first words in the lines alfabetical and than display it to a html file.

Al i need to know is how to sort them alfabetical.

You should be able to pass a reference to a subroutine to the sort command. This reference would compare two values and determine which one came first alphabetically.


From perldoc -f sort
                   # sort using explicit subroutine name
                   sub byage {
                       $age{$a} <=> $age{$b};  # presuming numeric
                   }
                   @sortedclass = sort byage @class;


Or you could try putting 'use locale' at the top of your script, to get it to sort by your local standards of alphabetical. Again from perldoc -f sort,
When `use locale' is in effect, `sort LIST' sorts
LIST according to the current collation locale.
See the perllocale manpage.


The perlfaq has some questions and answers about sorting stuff, too.

-Jeff Lowrey

Reply via email to