<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>

CC BY-SA 3.0
2016-04-05T13:39:50.513Z
Ah - perfect thank you, Brandon! I wasn't sure if there was an additional call I needed to make.
Damon
CC BY-SA 3.0
2016-04-05T09:33:33.287Z
2016-04-05T09:33:33.287Z
Brandon Kelly
<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>

CC BY-SA 3.0
2016-04-05T13:40:31.297Z
Thank you, Carlcs - I have everything set up - I should have just given it a shot in the first place :)
Damon
CC BY-SA 3.0
2016-04-05T04:52:14.570Z
2016-04-05T04:52:14.570Z
carlcs
<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>

<plugin-development><matrix>
How can I save matrix order via plugin?
# 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, Brandon! 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, Carlcs - I have everything set up - I should have just given it a shot in the first place :)  

---

