# Maximum with \`by\` keyword

**URL:** <https://discourse.julialang.org/t/maximum-with-by-keyword/86627>\
**Category:** General Usage\
**Created:** [September 1, 2022, 6:47am UTC](https://discourse.julialang.org/t/maximum-with-by-keyword/86627 "2022-09-01T06:47:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Post date:** [September 1, 2022, 6:47am UTC](https://discourse.julialang.org/t/maximum-with-by-keyword/86627/1 "2022-09-01T06:47:15Z")

</div>

I have a vector of `Tuple`s `v` for which I want to find the maximum based on, say, the first element of the `Tuple`.

`sort` has the `by` keyword: to sort the vector I would do `sort(v; by=x->x[1])`. What is the equivalent way for `maximum`?

---

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [September 1, 2022, 6:53am UTC](https://discourse.julialang.org/t/maximum-with-by-keyword/86627/2 "2022-09-01T06:53:06Z")

</div>

I think you might want `argmax(f, A)` which returns the value `x` in `A` for which `f(x)` is maximized. So in your case this could be `maxtuple = argmax(first, v)`.
