AJAX Forums

Sorting one array based on another one in javascript?

This is a discussion on Sorting one array based on another one in javascript? within the JavaScript forums, part of the Beginners AJAX category; I have two arrays. 1 array is an array of distances from a certain point. I know that if I want to sort this by shortest to farthest distance, that ...


Go Back   AJAX Forums > Beginners AJAX > JavaScript

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
Old 05-21-2007, 01:21 AM   #1 (permalink)
Junior Member
 
Join Date: May 2007
Posts: 1
Rep Power: 0 johndoi is on a distinguished road
Sorting one array based on another one in javascript?

I have two arrays. 1 array is an array of distances from a certain point. I know that if I want to sort this by shortest to farthest distance, that is easily done with an array sort. However, my other array is an array of city names that correspond with the distances in the first array. How could I sort the city array such that it would be identical to the distance array order after a numerical sort? Would it be easier to put them both into one array and some how specify to sort only the distance set? I wouldn't know how to do that. Thanks!I should have been a little more clear. I was trying to use the array.sort() function rather than writing a sort from scratch
__________________
johndoi is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Array Networks Builds On Green Credentials with New Virtualization Release microbee AJAX Help 0 06-02-2008 07:27 PM
xml to array in c#? Brady XML and XSLT 0 11-19-2007 09:52 AM
javascript dynamically generate multiple textboxes and forms based on pulldown menu? general_ya JavaScript 0 06-02-2007 09:53 AM
Javascript- Location based on IP address? AVSrocks JavaScript 1 05-28-2007 12:31 PM
java 3D array? joker JavaScript 1 05-21-2007 01:21 AM


All times are GMT -4. The time now is 08:42 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5
Copyright ©2006 - 2008, AJAXwith.com