[x]Register Now
Check out our brand new Local Poker Communities! Get updates and interact with poker players in your area.
Visit the United States Poker Community | Visit the California Poker Community | Read more about the Launch of P5s Local
Visit the United States Poker Community | Visit the California Poker Community | Read more about the Launch of P5s Local
-
Hi, I have some arrays, i think the term may be associated arrays or linked arrays, that are linked by index number. For example, I have an array called foodname and an array called foodprice, with foodname[1] corresponding to foodprice[1] and so on. I need to sort these arrays alphabetically by foodname. So when foodname is sorted, the corresponding foodprice value is not lost, it is sorted to the same index position. These values are actually kept as session variables, my session structure is called session.cart, and the arrays are called session.cart.foodname and session.cart.foodprice. I dont know if this changes anything. Can anyone help me with this? Thanks a lot.
-
OT?
-
Does it have to be done like this? It would be better to make a food class with two properties: name and price. Then you don't have to keep track of two different arrays. If you must use two arrays then something like this would work:
foodname.sort(Array foodprice)
{
whenever exchanging values in foodname
{
temp = foodname[i];
foodname[i] = foodname[j];
foodname[j] = temp;
temp = foodprice[i];
foodprice[i] = foodprice[j];
foodprice[j] = temp;
}
}
Similar Threads
- 9 Replies
- 1 Replies
-
21 Replies
Sort of going pro sort of kind of (not really) advice still appreciated
By StLouisNate in Poker Discussion
Last Post: Oct 6th, 2007, 02:12 AM - 4 Replies
- 4 Replies










