# Sorting lists/typles

**URL:** <https://forum.codewithmosh.com/t/sorting-lists-typles/10061>\
**Category:** Python\
**Created:** [January 19, 2022, 12:25pm UTC](https://forum.codewithmosh.com/t/sorting-lists-typles/10061 "2022-01-19T12:25:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![uLN](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/uln/32/3084_2.png) [@uLN](https://forum.codewithmosh.com/u/uLN)\
**Post date:** [January 19, 2022, 12:25pm UTC](https://forum.codewithmosh.com/t/sorting-lists-typles/10061/1 "2022-01-19T12:25:56Z")

</div>

What if there are three parts: Product name, price and date (that is, (“Product1”, 10, “12 January”)?

I want to order the following items according to the date. Any help would be appreciated

```auto
items = [
    ("Product1", "10", "Jan 24"),
    ("Product2", "9", "Jan 13"),
    ("Product3", "12""Jan 25"),
]

```

---

<div class="post-metadata">

**Author:** ![uLN](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/uln/32/3084_2.png) [@uLN](https://forum.codewithmosh.com/u/uLN)\
**Post date:** [January 19, 2022, 12:54pm UTC](https://forum.codewithmosh.com/t/sorting-lists-typles/10061/2 "2022-01-19T12:54:58Z")

</div>

Finally! I got what the number in square brackets as in

```auto
item[1]

```

So, just put 2 instead of 1! The number is the index of each item in the list!  
Product1, 12, Jan. 15  
\_\_\_\_0\_\_\_\_\_\_\_1\_\_\_\_2

```auto
items.sort(key=lambda item:item[2])

print(items)

```
