add sorted matrix for much faster rarity