This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Sorting a javascript array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Sorting a javascript array" Watch "Sorting a javascript array" New topic

Sorting a javascript array

Alan Gibson

Joined: Nov 23, 2006
Posts: 1
I have an array which contains a mixture of strings and numbers representing an address line. For example "20 Main Street" etc

I have found examples of functions which sort alphabetically or which sort numerically. Using the alphabetic sort would mean that for example "16 Main St", would come before "2 Main Street".

Does anyone have an example of a function which would sort this kind of mixed data satisfactorily?

Thanks in advance
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60752

I'd suggest googling for sort alogrithms. Just about any of them could be adapted to Javascript.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
It is sorta covered in the JavaRanch Style Guide.
subject: Sorting a javascript array
Similar Threads
LinkedList & Add Method?
Rather confused -------External classes!!
Help needed in how to update info in a randomaccessfile
Appending two Multidimensional Arrays together