Reputation: 6959
I am using g:each to iterate the list.My problem is the order of displaying the values is different when i refresh the page or reload the page. The values must have the same order for each time My code is
<g:each in="${litter.father.genotypes}" var="type">
<li><strong>${type.gene.name}:</strong> ${type.value.value}</li>
</g:each>
Upvotes: 0
Views: 743
Reputation: 180
You may be use the sort{} closure that provide a defined order by you:
<g:each in="${litter.father.genotypes.sort{it.name}}" var="type">
<li><strong>${type.gene.name}:</strong> ${type.value.value}</li>
</g:each>
In this sample the list is order by genotype's name, you shoul sort the list with the required attribute or an attribute from another class relation.
Regards.
Upvotes: 1
Reputation: 171074
I assume litter.father.genotypes
is a Set
?
If you convert it to a datatype that has an order (TreeSet
, List
, etc) the order should remain the same
Upvotes: 2