1 respuesta

If your priorities always are sequential integers, you put items into List in order of priority making the List index equivalent to the priority (or priority minus one if you do not have a priority zero). If you then use the remove(index) method to grab the item you are moving around, the other items in the list automatically reshuffle. If you then use add(index, item), you will force the items at and after this index to push back. This should work but other thought was to create a new List that you fill in three parts. First with loop through indexes before the one you want to set, add the item where you want it, then loop for the indexes you stopped at before to the end.I hope that helps. Reference: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_list.htmRespectfully yours, Kevin