daniel-eh
daniel-eh

Reputation: 414

Sort list of custom objects based on comparison to string

I'm looking to sort a list based on most closely matching to a query. So for my case, I have a custom object called movie, which has several fields, the one I'm concerned with is title. When I do the search, the OMDb API returns some results but unfortunately, the API's results are a little wonky sometimes in the way they're sorted.

For instance, searching "Guard" returns "The Old Guard" first, even before movies titled "Guard" and "The Guard". So what I'm looking to do is take the query string, in this case "guard", and sort the list of movie results based on how closely movie.title matches the query. I'm using an ArrayList to store these objects. Thanks for any help.

Upvotes: 0

Views: 152

Answers (0)

Related Questions