Does Grid.setItems() keep order ?

Let’s assume this code:

Grid<Car> carGrid = new Grid(Car.class);
List<Cars> sortedCars = customSorting();

carGrid.setItems(sortedCars); 

Is it guaranteed that carGrid items will be exactly in order described by customSorting, even if I try to display them to the user ? If no how can I achieve this behaviour? I didn’t find any detailed documentation on this.

I think that if you’re setting a Collection implementation that retains order, the Grid will too. It is said in the API documentation that “The provided collection instance may be used as-is.” and I would interpret it this way. You can also set a custom sort order for the data with [grid.setSortOrder(List<SortOrder<T>)]
(https://vaadin.com/api/framework/8.7.1/com/vaadin/ui/Grid.html#setSortOrder-java.util.List-).