lib/items.rb
# Sort items and add links to next/prev
Sort items and add links to next/prev
Sort items and add links to next / prev
def sort_items_collection()
  $alls_alt = Hash.new
  $items_collections.each { |k, v|
		result = v.sort {|left, right| (@items[left])[:date] <=> (@items[right])[:date]}
    	$alls_alt[k] = result
  }
  $items_collections = $alls_alt
  $items_collections.each { |k,arr|
    arr.each_with_index { |it, ndx|
      if (ndx > 0)
        @items[it][:prev] = arr[ndx - 1]
      end
      if (ndx < arr.size - 1)
        @items[it][:next] = arr[ndx + 1]
      end
    }
  }
end
def sort_items_collection ( ) $alls_alt = Hash . new $items_collections . each { | k , v | result = v . sort { | left , right | ( @items [ left ] ) [ :date ] <=> ( @items [ right ] ) [ :date ] } $alls_alt [ k ] = result } $items_collections = $alls_alt $items_collections . each { | k , arr | arr . each_with_index { | it , ndx | if ( ndx > 0 ) @items [ it ] [ :prev ] = arr [ ndx - 1 ] end if ( ndx < arr . size - 1 ) @items [ it ] [ :next ] = arr [ ndx + 1 ] end } } end
Sort items and add links to next/prev
Sort items and add links to next / prev
# prev/next