# The sorting of Tuples

**URL:** <https://discourse.julialang.org/t/the-sorting-of-tuples/6682>\
**Category:** General Usage\
**Tags:** tuple, sort\
**Created:** [October 25, 2017, 6:21pm UTC](https://discourse.julialang.org/t/the-sorting-of-tuples/6682 "2017-10-25T18:21:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ward9250](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ward9250/32/42768_2.png) [@Ward9250](https://discourse.julialang.org/u/Ward9250)\
**Post date:** [October 25, 2017, 6:21pm UTC](https://discourse.julialang.org/t/the-sorting-of-tuples/6682/1 "2017-10-25T18:21:48Z")

</div>

If I have an array of tuples, all of type Tuple{Int, X, X} where X is any other type. When I sort them with julia’s sort! api, can I rely on it to sort them by the first Int (I want the first Int to be treated as a rank)?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [October 25, 2017, 6:24pm UTC](https://discourse.julialang.org/t/the-sorting-of-tuples/6682/2 "2017-10-25T18:24:07Z")

</div>

Yes.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [October 25, 2017, 6:50pm UTC](https://discourse.julialang.org/t/the-sorting-of-tuples/6682/3 "2017-10-25T18:50:49Z")

</div>

Although note that if you have any identical integers, then it’ll try to compare the next object(s) and sort on those.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [October 25, 2017, 7:16pm UTC](https://discourse.julialang.org/t/the-sorting-of-tuples/6682/4 "2017-10-25T19:16:36Z")

</div>

This really needs to be documented: [https://github.com/JuliaLang/julia/issues/24330](https://github.com/JuliaLang/julia/issues/24330)
