Command disabled: revisions

Sorting an Array by Multiple Properties or Objects

Use the Ruby sort_by method (available to all enumerables, not just arrays). A direct “reassignment” of the array variable does not seem to work, you have to empty the array first:

    prices = (@period.prices.sort_by {|p| [p.invoice_item_type.asset_type.name, p.invoice_item_type.label] })
    @period.prices = []
    @period.prices = prices

Personal Tools