How to create a custom "group by" function with Links list