# Faster Sorting With GPU?

**URL:** <https://discourse.julialang.org/t/faster-sorting-with-gpu/8409>\
**Category:** New to Julia\
**Tags:** gpu, sort, arrays\
**Created:** [January 16, 2018, 5:55pm UTC](https://discourse.julialang.org/t/faster-sorting-with-gpu/8409 "2018-01-16T17:55:18Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![foobar\_lv2](https://avatars.discourse-cdn.com/v4/letter/f/ee59a6/32.png) [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Post date:** [January 17, 2018, 1:57pm UTC](https://discourse.julialang.org/t/faster-sorting-with-gpu/8409/23 "2018-01-17T13:57:47Z")

</div>

Ok, that’s much cleaner than my SVector variant. Forget my code and use this if you can live with the transposed memory layout.

---

<div class="post-metadata">

**Author:** ![judsoncs](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@judsoncs](https://discourse.julialang.org/u/judsoncs)\
**Post date:** [January 17, 2018, 5:14pm UTC](https://discourse.julialang.org/t/faster-sorting-with-gpu/8409/24 "2018-01-17T17:14:12Z")

</div>

But could I use multiple keys with that method?

---

<div class="post-metadata">

**Author:** ![simonbyrne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simonbyrne/32/19_2.png) [@simonbyrne](https://discourse.julialang.org/u/simonbyrne)\
**Post date:** [January 17, 2018, 6:46pm UTC](https://discourse.julialang.org/t/faster-sorting-with-gpu/8409/26 "2018-01-17T18:46:50Z")

</div>

> [@judsoncs](#):
>
> But could I use multiple keys with that method?

You can use the `by` or `lt` options to specify the sorting criteria, e.g.

```julia
sort(Atup; alg=QuickSort, by=x->(x[3],x[1],x[2]))

```

will sort by the 3rd column, the 1st column, then the 2nd column (since tuples are compared by [lexicographic order](https://en.wikipedia.org/wiki/Lexicographical_order) of the elements)

---

<div class="post-metadata">

**Author:** ![judsoncs](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@judsoncs](https://discourse.julialang.org/u/judsoncs)\
**Post date:** [January 17, 2018, 7:44pm UTC](https://discourse.julialang.org/t/faster-sorting-with-gpu/8409/27 "2018-01-17T19:44:18Z")

</div>

I’ve used that format for the sortrows function but it doesn’t seem to work with the sort function.

---

<div class="post-metadata">

**Author:** ![simonbyrne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simonbyrne/32/19_2.png) [@simonbyrne](https://discourse.julialang.org/u/simonbyrne)\
**Post date:** [January 17, 2018, 7:51pm UTC](https://discourse.julialang.org/t/faster-sorting-with-gpu/8409/28 "2018-01-17T19:51:03Z")

</div>

what format? It worked using @sdanisch’s example.

---

<div class="post-metadata">

**Author:** ![judsoncs](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@judsoncs](https://discourse.julialang.org/u/judsoncs)\
**Post date:** [January 17, 2018, 9:00pm UTC](https://discourse.julialang.org/t/faster-sorting-with-gpu/8409/29 "2018-01-17T21:00:35Z")

</div>

Ok yeah you’re right, it works. Sorry!

[Previous page](https://discourse.julialang.org/t/faster-sorting-with-gpu/8409.md?page=1)
