# How to reorder collection items?

**URL:** <https://discourse.getcockpit.com/t/how-to-reorder-collection-items/2689>\
**Category:** Support\
**Created:** [February 5, 2023, 10:45pm UTC](https://discourse.getcockpit.com/t/how-to-reorder-collection-items/2689 "2023-02-05T22:45:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rew](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@rew](https://discourse.getcockpit.com/u/rew)\
**Post date:** [February 5, 2023, 10:45pm UTC](https://discourse.getcockpit.com/t/how-to-reorder-collection-items/2689/1 "2023-02-05T22:45:06Z")

</div>

I’m trying out the collection/list type to see how it compares to a singleton type that contains a set (comparing to tree is next - really wish the docs had some better discussion around these types and what use-cases are better suited for which types). One aspect that I seem to be stuck on is item sorting. What I want to do is give the content management users the ability to reorder items in a collection by dragging them, which would affect the order of the items as the API receives them (assuming the API call isn’t otherwise overriding the order).

With the singleton/set, this can be done by dragging items around in the UI, but that doesn’t seem to be supported with the collection/list type as there are no drag handles. I looked for an option to enable it, but the only options I see are for color, icon, and revisions.

Digging around this forum, I’ve found references to a “custom sortable entries” option, but I don’t see that anywhere. Maybe it was removed or renamed at some point?

Is there any way to accomplish this?

---

<div class="post-metadata">

**Author:** ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)\
**Post date:** [February 5, 2023, 10:57pm UTC](https://discourse.getcockpit.com/t/how-to-reorder-collection-items/2689/2 "2023-02-05T22:57:55Z")

</div>

Hey 👋

For such use-case use the tree model type. To prevent nesting items you can set the maxlevel to `0` in the model meta options:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/getcockpit/original/2X/8/88db38b58e5768de6b128ee717f2678e641a89a9.png)

When requesting the items via api, sort by the internal `_o` field:

```auto
/api/content/items/[modelname]?sort={_o:1}

```

---

<div class="post-metadata">

**Author:** ![rew](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@rew](https://discourse.getcockpit.com/u/rew)\
**Post date:** [February 6, 2023, 11:39pm UTC](https://discourse.getcockpit.com/t/how-to-reorder-collection-items/2689/3 "2023-02-06T23:39:58Z")

</div>

That worked great, thank you!
