;; find the max :timestamp in a collection of maps.
user=> (def mmm [
{:timestamp 1 :name "v"}
{:timestamp 2 :name "q"}
{:timestamp 3 :name "r"}])
user=> (apply max-key :timestamp mmm)
{:timestamp 3, :name "r"}
user=> (:timestamp (apply max-key :timestamp mmm))
3
;;if the map is indexed by item-id, use an anonymous function where the key goes.
user=> (def map-with-index {
"gary" {:timestamp 1 :name "v"}
"carl" {:timestamp 2 :name "q"}
"lola" {:timestamp 3 :name "r"}})
user=> (apply max-key #(:timestamp (val %)) map-with-index)
["lola" {:timestamp 3, :name "r"}]
;notice how we replaced :timestamp with #(:timestamp (val %))
;to get the inner value [and not the (key %)] of the indexed version.