# Dictionary of all indices of all unique values in an array

**URL:** <https://discourse.julialang.org/t/dictionary-of-all-indices-of-all-unique-values-in-an-array/939>\
**Category:** General Usage\
**Created:** [December 14, 2016, 12:04pm UTC](https://discourse.julialang.org/t/dictionary-of-all-indices-of-all-unique-values-in-an-array/939 "2016-12-14T12:04:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [December 14, 2016, 12:04pm UTC](https://discourse.julialang.org/t/dictionary-of-all-indices-of-all-unique-values-in-an-array/939/1 "2016-12-14T12:04:40Z")

</div>

`StatsBase.indexmap(a)` creates a dictionary of indices of first occurrences of all unique values in `a`.

Is there a standard function that would create a map to all indices of all unique values in `a` (not only the first one). I am thinking of a function like:

```julia
function indexmapall{T}(a::AbstractArray{T})
    d = Dict{T,Vector{Int}}()
    for (i, k) = enumerate(a)
        push!(get!(d, k, []), i)
    end
    return d
end

```
