title: Spring Data JPA - Custom Sort in JpaRepository
body: <p>I am using Spring Data JPA with Spring Data REST and i have created a JpaRepository for my <code>Thing</code> entity.</p>
  
  <pre><code>@Repository
  public interface ThingRepository extends JpaRepository&lt;Thing, Long&gt; {
  
      @RestResource(path = "findByName", rel = "findByName")
      Page findByName(@Param("name") String name, Pageable page);
  
  }
  </code></pre>
  
  <p>I want to apply sorting. I want to sort the <code>Thing</code> List based on a custom rating  algorithm. </p>
  
  <pre><code>List&lt;Thing&gt; sortByRating(List&lt;Thing&gt; things){
  
      // custom logic
  
      return things;
  };
  </code></pre>
  
  <p>I would like if possible to use a custom function in order to sort the results. What is the best approach to this kind of thing in Spring JPA? How can i make my Repository use my function to sort the result set?</p>