Make lore sorting more efficient