Answers.Body: <p>Matrix blocks are saved in the order they appear in the POST data when saving the "owner" element (the entry, or whatever). So just adding jQuery Sortable to your front-end form will be enough.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-05T13:39:50.513Z
Answers.Text: Ah - perfect thank you, Brandon! I wasn't sure if there was an additional call I needed to make.
Answers.UserDisplayName: Damon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-05T09:33:33.287Z
Answers.LastActivityDate: 2016-04-05T09:33:33.287Z
Answers.UserDisplayName: Brandon Kelly
Answers.Body: <p>You'd re-save the element with the field set to the re-ordered array of IDs representing the Matrix blocks.</p>
  
  <p>You don't have to save the blocks themselves, just the element.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-05T13:40:31.297Z
Answers.Text: Thank you, Carlcs - I have everything set up - I should have just given it a shot in the first place :)
Answers.UserDisplayName: Damon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-05T04:52:14.570Z
Answers.LastActivityDate: 2016-04-05T04:52:14.570Z
Answers.UserDisplayName: carlcs
Body: <p>I am able to add/delete matrix blocks from within my plugin without any problems. I would like to give the user the ability to drag &amp; drop any field just as you can within the CP.</p>
  
  <p>I can use <a href="https://jqueryui.com/sortable/" rel="nofollow">jQuery UI Sortable</a> to create the functionality no problem. I am curious what/how to call within Craft that manages order so that it is saved.</p>
  
  <p>Thank you for any suggestions! </p>
  
Tags: <plugin-development><matrix>
Title: How can I save matrix order via plugin?
ThreadText: # How can I save matrix order via plugin?
  
  (Asked by: username_0 on 2016-04-05)
  
  I am able to add/delete matrix blocks from within my plugin without any problems. I would like to give the user the ability to drag & drop any field just as you can within the CP.
  
  I can use [jQuery UI Sortable](https://jqueryui.com/sortable/) to create the functionality no problem. I am curious what/how to call within Craft that manages order so that it is saved.
  
  Thank you for any suggestions!
  
  **Tags:** plugin-development, matrix
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-04-05. Score: 1 | Accepted answer
  
  Matrix blocks are saved in the order they appear in the POST data when saving the "owner" element (the entry, or whatever). So just adding jQuery Sortable to your front-end form will be enough.
  
  > **Comments:**
  > **username_0**: Ah - perfect thank you, username_1! I wasn't sure if there was an additional call I needed to make.  
  
  ---
  
  ### Answer by username_2 on 2016-04-05. Score: 0
  
  You'd re-save the element with the field set to the re-ordered array of IDs representing the Matrix blocks.
  
  You don't have to save the blocks themselves, just the element.
  
  > **Comments:**
  > **username_0**: Thank you, username_2 - I have everything set up - I should have just given it a shot in the first place :)  
  
  ---
  
  