Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sorting a javascript array

 
Alan Gibson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 65228
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd suggest googling for sort alogrithms. Just about any of them could be adapted to Javascript.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic