Hi Jim

This does seems kinda expensive, turning a String into an integer for each
value thats being compared in a collection. I would have thought it would be
better making a small object that contained the String and the number.
Something along the lines of

public class NumericString implements Comparable {
    private String text;
    private int number;

    ...
}

then at least the conversion from String to int is done only once per
NumericString construction, not twice per comparison of values.

James
----- Original Message -----
From: "Jim Cheesman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 30, 2001 4:02 PM
Subject: [Collections] NumericComparator


> I'm not sure if this is suitable for inclusion in collections - but I've
> found it to be fairly useful when comparing StringS.
>
> The problem solved:
> Does 11 come before or after 2,3,4,5...?
>
> Other features:
> Ascending/descending comparison
> Blanks are high/low.
>
>
> I've included the test case class.
>
>
> Salu2.
> Jim
>
>
>
>
>


----------------------------------------------------------------------------
----


>
> --
>
>                            *   Jim Cheesman   *
>              Trabajo:
> [EMAIL PROTECTED] - (34)(91) 724 9200 x 2360
>               Exaggeration is not
> all it's cracked up to be.
>
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

Reply via email to