# 502 error on Re-Order Categories

**URL:** https://meta.discourse.org/t/502-error-on-re-order-categories/384185
**Category:** Support
**Tags:** categories
**Created:** [September 27, 2025, 6:43pm UTC](https://meta.discourse.org/t/502-error-on-re-order-categories/384185 "2025-09-27T18:43:04Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 27, 2025, 9:47pm UTC](https://meta.discourse.org/t/502-error-on-re-order-categories/384185/4 "2025-09-27T21:47:58Z")

</div>

Here’s something I recommended to someone else (that I still haven’t tested).

> [@Ordering categories is quite glitched when the numbers get high](https://meta.discourse.org/t/ordering-categories-is-quite-glitched-when-the-numbers-get-high/367677/2):
>
> Yeah. I once wrote some code to alphabetize them at the rails console, I think, but I don’t see it at hand. You can probably get [https://ask.discourse.com/](https://ask.discourse.com/) or some other AI to give you some code to do it. . .. Well, I couldn’t. This might work, but I didn’t try it. cats = Category.where("parent\_category\_id is not null").pluck(:parent\_category\_id).uniq cats.each do |cat| subs = Category.where(parent\_category\_id: cat.id) subs\_sorted = subs.sort\_by { |c| c.name.downcase } pos = 10 s…

---

_[View the full topic](https://meta.discourse.org/t/502-error-on-re-order-categories/384185)._
