# Sort multidimensional array based on second part in first column

**URL:** <https://forum.inductiveautomation.com/t/sort-multidimensional-array-based-on-second-part-in-first-column/31811>\
**Category:** General Discussion\
**Created:** [January 31, 2020, 7:34am UTC](https://forum.inductiveautomation.com/t/sort-multidimensional-array-based-on-second-part-in-first-column/31811 "2020-01-31T07:34:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andreas/32/18981_2.png) [@andreas](https://forum.inductiveautomation.com/u/andreas)\
**Post date:** [January 31, 2020, 7:34am UTC](https://forum.inductiveautomation.com/t/sort-multidimensional-array-based-on-second-part-in-first-column/31811/1 "2020-01-31T07:34:03Z")

</div>

I have a multidimensional array like:

```auto
Array = [[142 Bob,9,70],[152 Abe,152,0],[14267 Mike,98,8]]
```

I need to sort it based on the names in the first column, so that I end up with:

```auto
SortedArray = [[152 Abe,152,0],[142 Bob,9,70],[14267 Mike,98,8]]
```

I have tried using the sorted-method like:

```auto
SortedArray = sorted(Array, key=lambda x:x[0])
```

This will sort the array, but it will sort based on the number in the first column and not the name.

Any ideas on how to solve this?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 31, 2020, 11:56am UTC](https://forum.inductiveautomation.com/t/sort-multidimensional-array-based-on-second-part-in-first-column/31811/2 "2020-01-31T11:56:51Z")

</div>

```auto
>>> Array = [["142 Bob",9,70],["152 Abe",152,0],["14267 Mike",98,8]]
>>> SortedArray = sorted(Array, key=lambda x: x[0].split()[1])
>>> print SortedArray
[['152 Abe', 152, 0], ['142 Bob', 9, 70], ['14267 Mike', 98, 8]]
>>>

```
