# How to get vector of tuples from the vector of tuples using certain conditions?

**URL:** <https://discourse.julialang.org/t/how-to-get-vector-of-tuples-from-the-vector-of-tuples-using-certain-conditions/84205>\
**Category:** General Usage\
**Tags:** question\
**Created:** [July 14, 2022, 4:35am UTC](https://discourse.julialang.org/t/how-to-get-vector-of-tuples-from-the-vector-of-tuples-using-certain-conditions/84205 "2022-07-14T04:35:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phuntsho](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phuntsho/32/46546_2.png) [@Phuntsho](https://discourse.julialang.org/u/Phuntsho)\
**Post date:** [July 14, 2022, 4:35am UTC](https://discourse.julialang.org/t/how-to-get-vector-of-tuples-from-the-vector-of-tuples-using-certain-conditions/84205/1 "2022-07-14T04:35:49Z")

</div>

I have a vector containing tuples and I want to extract some tuples that meet certain conditions. I tried something as shown below but didn’t get the expected result.

```julia
A = [(1,2),(3,2),(3,4),(5,4),(3,2)]
A_c = findall(x->x[2] <= 2, A)
# I get A_c = [1,2,5], but I need A_c = [(1,2),(3,2),(3,2)]

```

Your help will be highly appreciated.

---

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [July 14, 2022, 4:39am UTC](https://discourse.julialang.org/t/how-to-get-vector-of-tuples-from-the-vector-of-tuples-using-certain-conditions/84205/2 "2022-07-14T04:39:07Z")

</div>

```julia
julia> A[A_c]
3-element Vector{Tuple{Int64, Int64}}:
 (1, 2)
 (3, 2)
 (3, 2)

```

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [July 14, 2022, 4:42am UTC](https://discourse.julialang.org/t/how-to-get-vector-of-tuples-from-the-vector-of-tuples-using-certain-conditions/84205/3 "2022-07-14T04:42:35Z")

</div>

```julia
julia> [a for a in A if a[2]<=2]
3-element Vector{Tuple{Int64, Int64}}:
 (1, 2)
 (3, 2)
 (3, 2)

```

* * *

```julia
julia> filter(x->x[2]<=2, A)
3-element Vector{Tuple{Int64, Int64}}:
 (1, 2)
 (3, 2)
 (3, 2)

```
