# Add support for indexing \`SparseMatrixCSC\` by using arrays of \`CartesianIndex{N}\`

**URL:** <https://discourse.julialang.org/t/add-support-for-indexing-sparsematrixcsc-by-using-arrays-of-cartesianindex-n/17906>\
**Category:** General Usage\
**Created:** [November 23, 2018, 2:29pm UTC](https://discourse.julialang.org/t/add-support-for-indexing-sparsematrixcsc-by-using-arrays-of-cartesianindex-n/17906 "2018-11-23T14:29:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nangeschnappt](https://avatars.discourse-cdn.com/v4/letter/n/ed655f/32.png) [@nangeschnappt](https://discourse.julialang.org/u/nangeschnappt)\
**Post date:** [November 23, 2018, 2:29pm UTC](https://discourse.julialang.org/t/add-support-for-indexing-sparsematrixcsc-by-using-arrays-of-cartesianindex-n/17906/1 "2018-11-23T14:29:18Z")

</div>

On `0.7.0`

```julia
using LinearAlgebra, SparseArrays
m = 2
A = sparse(1.0I, m, m)
ind = [CartesianIndex(i, i) for i = 1:m]

```

```julia
julia> A[ind]

MethodError: no method matching isless(::CartesianIndex{2}, ::Int64)
Closest candidates are:
  isless(!Matched::Missing, ::Any) at missing.jl:66
  isless(!Matched::AbstractFloat, ::Real) at operators.jl:150
  isless(!Matched::Real, ::Real) at operators.jl:338
  ...

Stacktrace:
 [1] <(::CartesianIndex{2}, ::Int64) at .\operators.jl:260
 [2] getindex(::SparseMatrixCSC{Float64,Int64}, ::Array{CartesianIndex{2},1}) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\SparseArrays\src\sparsevector.jl:667
 [3] top-level scope at In[4]:1

```

Is this related to [SparseMatrixCSC as a general sparse container: Setindex!(...) not working for SparseMatrixCSC with vector elements (v0.7)](https://discourse.julialang.org/t/sparsematrixcsc-as-a-general-sparse-container-setindex-not-working-for-sparsematrixcsc-with-vector-elements-v0-7/14529)?
