Creating a Custom Comparator for pushing elements into any Data Structure

Hey! So basically what I am trying to do is trying to create a Heap like structure where I want to compare the values of two structs and using that as the basis, want to insert into the data structure with the larger one being inserted before.

Is there anyway to write a comparator function and use that as the basis of insertion into lists or similar data structures?

Enum.sort/2 is a good example to follow, in particular the version where you pass it a module name (like DateTime) and it calls compare/2 from that module.