# Findall((in)) returns non-sorted array for Int64

**URL:** https://discourse.julialang.org/t/findall-in-returns-non-sorted-array-for-int64/20556
**Category:** New to Julia
**Tags:** question
**Created:** [February 7, 2019, 5:14pm UTC](https://discourse.julialang.org/t/findall-in-returns-non-sorted-array-for-int64/20556 "2019-02-07T17:14:01Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ezgikurt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ezgikurt/32/7017_2.png) [@ezgikurt](https://discourse.julialang.org/u/ezgikurt)
#### Post date: [February 7, 2019, 5:14pm UTC](https://discourse.julialang.org/t/findall-in-returns-non-sorted-array-for-int64/20556/1 "2019-02-07T17:14:01Z")

</div>

Hi,

I’m trying to find where the elements of an Array{Int64,1} are indexed in another Array{Int64,1}. I’m trying something like the following (but b and a are much longer).

```julia
b = [7;3];
a = 1:10;
c = findall((in)(b), a);

c = [3;7]

```

Is there a way to have this sorted? i.e I want c to be [7;3].

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [February 7, 2019, 5:16pm UTC](https://discourse.julialang.org/t/findall-in-returns-non-sorted-array-for-int64/20556/2 "2019-02-07T17:16:09Z")

</div>

It is sorted — in ascending order. Use `reverse(c)`.

PS: also, please [quote your code](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530).

---

<div class="post-metadata">

### Author: ![ezgikurt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ezgikurt/32/7017_2.png) [@ezgikurt](https://discourse.julialang.org/u/ezgikurt)
#### Post date: [February 7, 2019, 5:56pm UTC](https://discourse.julialang.org/t/findall-in-returns-non-sorted-array-for-int64/20556/3 "2019-02-07T17:56:40Z")

</div>

Hi, unfortunately that doesn’t work - i think i wasn’t clear in my example, here’s a better one. `a` is not in ascending order, it is just an Array of random integers and `b` has more than 2 elements. See the following example:

```julia
a = [3;11;18;7;27;5];
b = [3;5;7];
c = findall((in)(b),a);

c
3-element Array{Int64,1}:
 1
 4
 6

reverse(c)
3-element Array{Int64,1}:
 6
 4
 1

```

But i want it to return [1;6;4] of course.

---

<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: [February 7, 2019, 5:58pm UTC](https://discourse.julialang.org/t/findall-in-returns-non-sorted-array-for-int64/20556/4 "2019-02-07T17:58:36Z")

</div>

You want a different operation entirely: [`indexin`](https://docs.julialang.org/en/v1/base/collections/#Base.indexin).

```julia
julia> indexin(b, a)
3-element Array{Union{Nothing, Int64},1}:
 1
 6
 4

```

---

<div class="post-metadata">

### Author: ![ezgikurt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ezgikurt/32/7017_2.png) [@ezgikurt](https://discourse.julialang.org/u/ezgikurt)
#### Post date: [February 7, 2019, 6:17pm UTC](https://discourse.julialang.org/t/findall-in-returns-non-sorted-array-for-int64/20556/5 "2019-02-07T18:17:12Z")

</div>

great, thanks!
