Sorting Categories by Name

AI-generated summary

The discussion revolves around sorting categories by name in Discourse. csmu asks how to sort categories by name, and simon explains that enabling the fixed category positions setting allows reordering via the staff menu. pfaffman suggests using Ruby in the console for large numbers of categories. csmu inquires about the relevant field to change, then reports that reordering fails when moving a category above a subcategory, not a parent category. Stephen claims it works, suggesting possible customizations may interfere. csmu references a similar issue and eventually resolves the problem using SQL, sharing a solution in a meta post here.

How would you sort {host}/categories by name?

Are you trying to order categories on the Category page? If so, that can be done by enabling the fixed category positions Site Setting. When that setting is enabled, an option to Reorder Categories is added to the staff menu on the top-right of the category page.

If this isn’t what you’re looking for, let us know.

If you have more than 20 or so, a bit of ruby at the console can sort them all.

Do you know off hand the field that would have to be changed?

That looks cool and it looks like it would work.

It doesn’t work well with Categories with SubCategories.
Which I click on a main category to move up it doesn’t move.
Sub categories within a main category do move.

Is that a bug?

It works here. Could be customisations interfering with the page.

It works here as long as the item above is a parent category. It fails when the item above is a subcategory.

Is there an official way I can add a test that shows the problem (or not) … do the UI tests use Puppeteer or something similar?

The issue I’m seeing is pretty much the same as Reorder Categories behaving strangely

I ended up doing this via SQL.