# Sort array quickie

**URL:** <https://forum.kirupa.com/t/sort-array-quickie/269429>\
**Category:** Uncategorized\
**Created:** [August 27, 2008, 3:00pm UTC](https://forum.kirupa.com/t/sort-array-quickie/269429 "2008-08-27T15:00:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlk](https://avatars.discourse-cdn.com/v4/letter/m/e56c9b/32.png) [@mlk](https://forum.kirupa.com/u/mlk)\
**Post date:** [August 27, 2008, 3:00pm UTC](https://forum.kirupa.com/t/sort-array-quickie/269429/1 "2008-08-27T15:00:05Z")

</div>

Hello again

It’s another one of these days where I can’t get my head around php (and the fact that I code jscript at the same time just confuses me)

I’m trying to sort an array containing arrays by using elements of the arrays - how should I do that ?

```php

//here's what my array could look like
//I would for instance like to order my array (the top elements - fruitnames)
//by their color or the number or the type of food (fruit/veggie)

Array
(
    [apple] => Array
        (
            [0] => red
            [1] => Fruit
            [2] => 2
        )

    [salad] => Array
        (
            [0] => green
            [1] => vegetable
            [2] => 45
        )

    [carrot] => Array
        (
            [0] => orange
            [1] => vegetable
            [2] => 22
        )

)

```
