in reply to Re: sorting string
in thread sorting string

But how do I know which belong to which string? It will list something like this '123343322' so how do I save the list in a database for example? if it could list string1 = 122, string = 222, string 3 = 333... TQ

Replies are listed 'Best First'.
Re^3: sorting string
by davido (Cardinal) on Aug 28, 2005 at 16:29 UTC

    Yes, after posting my response it hit me that your question simply didn't ask what you wanted answered.

    Zaxo has it right; you probably want a hash with key/value relationship. Then you ultimately want the strings stored as keys, and the computed values as values associated with the keys. ...something like this:

    use strict; use warnings; my %strings; # Set up some example key/value relationships. Your method # for populating the hash will be more complex, but isn't # defined in the question. $strings{"Here is one string"} = 233; $strings{"Here is another string"} = 151; $strings{"Here is yet another"} = 322; print map{ "$_ = $strings{$_}\n" } sort{ $strings{$b} <=> $strings{$a} } keys %strings;

    Dave