Map instances by attribute and sort them