How to use SparseArray
Basic example using SparseArray