# Does it make sense for @orderby and @groupby not to commute?

**URL:** <https://discourse.julialang.org/t/does-it-make-sense-for-orderby-and-groupby-not-to-commute/45920>\
**Category:** New to Julia\
**Tags:** query\
**Created:** [September 1, 2020, 8:10pm UTC](https://discourse.julialang.org/t/does-it-make-sense-for-orderby-and-groupby-not-to-commute/45920 "2020-09-01T20:10:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![conditionality](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@conditionality](https://discourse.julialang.org/u/conditionality)\
**Post date:** [September 1, 2020, 8:10pm UTC](https://discourse.julialang.org/t/does-it-make-sense-for-orderby-and-groupby-not-to-commute/45920/1 "2020-09-01T20:10:09Z")

</div>

I have a dataframe which I want to group by some column value, and within each group I want the rows sorted by another column. I can do an **@orderby |\> @groupby** , however I feel like a **@groupby |\> @orderby** should make equally sense (perhaps not), but the latter is not possible. Somehow (perhaps naively, and falsely) I felt that **@orderby |\> @groupby** should be slower than **@groupby |\> @orderby** if one never does a “collect” (but I’m not sure this works under the hood).

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [September 2, 2020, 12:44am UTC](https://discourse.julialang.org/t/does-it-make-sense-for-orderby-and-groupby-not-to-commute/45920/2 "2020-09-02T00:44:51Z")

</div>

Can I suggest you mention the packages you are using.

Also surround code on both sides with ``` helps with visualation e.g.

```julia
@orderby |> @groupby

```

Also creating a Minimal Working Example (MWE) helps, see [Please read: make it easier to help you - #81](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757/81)

---

<div class="post-metadata">

**Author:** ![conditionality](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@conditionality](https://discourse.julialang.org/u/conditionality)\
**Post date:** [September 2, 2020, 6:05pm UTC](https://discourse.julialang.org/t/does-it-make-sense-for-orderby-and-groupby-not-to-commute/45920/3 "2020-09-02T18:05:39Z")

</div>

Sorry, I thought the tag would be enough. It’s Query.jl.
