Neta Meta
Neta Meta

Reputation: 4047

Is there a way to choose the sorting of ksort?

I have a use for ksort() and I need to choose the sorting order(ASC/DESC).

Is there a way of doing it without array_multisort()?

Upvotes: 42

Views: 33164

Answers (2)

Aryan Aly
Aryan Aly

Reputation: 208

Also :

krsort() function to sort an associative array in descending order, according to the key.
&
ksort for ascending order
plus
arsort() function to sort an associative array in ascending order, according to the value.

Upvotes: 7

Matthew
Matthew

Reputation: 11280

krsort() for descending order
ksort() for ascending order

Upvotes: 107

Related Questions