title: Grails - Sorting list output without having to have a SortedSet or Comparable model?
body: <p>I am banging my head up against the wall about what I think would be a very simple problem to resolve in Grails:</p>
  
  <p>Say that I have shopping-cart-like model; so a class Cart that hasMany items, and each item belongsTo the cart.  In general, I don't care about the order of the items in the cart - I don't care what order they're stored in, calculated in, etc.  HOWEVER, I do want to DISPLAY them in the same order.  It seems to me that this logic should be able to exist ENTIRELY in the view layer, but the only solutions I've been able to find tell me to declare items as a SortedSet in the model layer.  This also affects my controller layer, as simple List operations such as .collect{} now require extra syntactic jumping around to keep the type conversions correct and preserve my sorting.</p>
  
  <p>To me, this is nuts, so I must be missing something simple!  Is there any way, for example, to do something like <code>&lt;g:each in="${cart.items.sort{it.name}}"&gt;</code> or something similar, so that I can enforce a consistent display order ONLY at the output / view layer? EDIT - See Matt's answer below; a version of this does actually work.</p>
  
  <p>Thank you for any advice or pointers!</p>