# Sorting multi-dimesional arrays

**URL:** <https://forum.kirupa.com/t/sorting-multi-dimesional-arrays/271129>\
**Category:** programming\
**Created:** [September 18, 2008, 7:38pm UTC](https://forum.kirupa.com/t/sorting-multi-dimesional-arrays/271129 "2008-09-18T19:38:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NeoDreamer](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@NeoDreamer](https://forum.kirupa.com/u/NeoDreamer)\
**Post date:** [September 18, 2008, 7:38pm UTC](https://forum.kirupa.com/t/sorting-multi-dimesional-arrays/271129/1 "2008-09-18T19:38:10Z")

</div>

Say I have a multi-dimensional array:

```php

$arr[0][0] = 'pic0.jpeg';
$arr[0][1] = 'screenshot of videogame';
$arr[0][2] = 108.2;

$arr[1][0] = 'image.jpeg';
$arr[1][1] = 'someones face';
$arr[1][2] = 35.6;

$arr[2][0] = 'flower.jpeg';
$arr[2][1] = 'floral arrangement';
$arr[2][2] = 99.6;

// .... and so on...... 

```

Is there a library function that could sort the rows (entry for an image) by the third column (a numerical rating) while keeping each row intact? So the sorted array would be…

```php

$arr[0][0] = 'image.jpeg';
$arr[0][1] = 'someones face';
$arr[0][2] = 35.6;

$arr[1][0] = 'flower.jpeg';
$arr[1][1] = 'floral arrangement';
$arr[1][2] = 99.6;

$arr[2][0] = 'pic0.jpeg';
$arr[2][1] = 'screenshot of videogame';
$arr[2][2] = 108.2;

// .... and so on...... 

```
