Pregunta

I'm working on this playframework project. I have a list of ploegen and each ploeg has its punten. punten is an integer. I want to sort them by the value of punten. How can I do that?

This is the list I have now, it shows the plogen in the order they are stored in the database:

 <ul>
    @for(ploeg <- ploegen) {
        <li>
            @ploeg.naam
            @ploeg.punten
            @form(routes.Application.deletePloeg(ploeg.id)) {
                <input type="submit" value="Delete">
            }

        </li>
    }
</ul>
¿Fue útil?

Solución

As Robin said you should sort elements in backend. You can do it like this:

Finder<Long, Ploeg> find = new Finder<Long, Ploeg>(Long.class, Ploeg.class);
List<Ploeg> ploegen = find.orderBy("punten asc").findList();

Otros consejos

First, sorting should be done in the controller, in the code that accesses the database. You can use an EBean filter. That will sort in memory. I'm not familiar with Ebean so I don't know if there is a better way.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top