728x90
            // set gps
            Pageable pageWithSort = PageRequest.of(offset, pageSize, Sort.by("createdAt"));

Pageable support "WithSort" method and properties. Quote Below

 

 

https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/domain/Sort.html

 

 

 

 

withSort

public PageRequest withSort(Sort.Direction direction,
 String... properties)

Creates a new PageRequest with Sort.Direction and properties applied.

 

Parameters:
direction - must not be null.
properties - must not be null.

 

Returns:
a new PageRequest.

+ Recent posts