I’m new to F# and I’m working on a simple script to work with some data from an API. One of the values is a ‘rating’ of a company. The available ratings are “AAA”, “AA”, “A”, “BBB”, “BB”, “B”, and “CCC” in that order. I have a collection of companies where each one has a rating. I want to sort the companies by rating. However, if I use a normal sortBy, I’ll get “A” followed by “AA”, followed by “AAA”, etc. which isn’t what I want. Is there a simple way to define a custom sort function to handle collating? Is there some way I can define a ‘Rating’ type and specify the allowed values along with some functions to handle sorting? I’m looking for suggestions that might help me expand my knowledge of how to tackle a problem using F#.
Thanks. I was actually able to get what I wanted with a simple union type. I just needed to write a simple function to convert my input strings into the type.