Re: Function that compares 2 alpha-numeric values?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Function that compares 2 alpha-numeric values?

From: askMe <askMe@askblax.com>
Date: Fri Jul 22 2005 - 12:10:25 CEST

success_ny@yahoo.com wrote:
> Does anyone have a code snippet to compare those values so I can sort
> the array of alpha-numeric values that include both characters and
> integers in it?
>
> I.e., if we have values like 4236 and 123234, I want 4236 to be second
> because 4 is bigger than 1 rather than using the numeric comparison.
> The strings can include character values and strings. Basically, I have
> the bubble sort function, the question is how to compare those types of
> strings in the alpha-numeric order.
>
> i.e.,
>
> A83745
> B34974
> 127734
> 34456
> 788
>
> I looked all over the web thinking that this simple question would be
> answered somewhere, but could not find the answer. Please help.
>
> Thanks!

Try a loop over the whole set first to separate the numeric from the
alphas with isNan. Run a sort on the numbers array, then a sort on the
alpha array. Add the sort alpha array elements to the end of the
numeric array.

http://www.askblax.com
Received on Tue Oct 18 02:59:45 2005