insertion sort and part of LRU cache