Jump to content

[SOLVED] Quick Array Sorting Question


Flames

Recommended Posts

I need to be able to quickly sort an array (key and value kept corresponding), but instead of using letters i want to use numbers, i looked over all the sort functions and krsort seems the most like what i need, a reverse sort of the keys maintaining the value it has but with numbers, so 999 => value1, 1000 => value2, 998 => value3 would become 1000 => value2, 999 => value1, 998 => value3, and if krsort is the right one if i was to use a foreach loop, would the foreach to the array in the sorted order so 1000 first, or would it do it in an normal numeric/alphabetic order 1,2,3,4,5 (a,b,c,d,e) etc

Link to comment
https://forums.phpfreaks.com/topic/141357-solved-quick-array-sorting-question/
Share on other sites

sorting alphabetically which is what it did.

BTW CV liking the sig, dynamic images ftw.

 

I think you are misunderstanding.  There is no such thing as sorting alphabetically vs. numerically.  I think you are talking about sorting by key vs. value.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.