# סידור הקטגוריות תקול כשהמספרים עולים

**URL:** https://meta.discourse.org/t/ordering-categories-is-quite-glitched-when-the-numbers-get-high/367677
**Category:** Bug
**Created:** [27 במאי,‏ 2025,‏ 12:29am UTC](https://meta.discourse.org/t/ordering-categories-is-quite-glitched-when-the-numbers-get-high/367677 "2025-05-27T00:29:38Z")
**Posts on this page:** 1
**Showing post:** 2

<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: [27 במאי,‏ 2025,‏ 7:50pm UTC](https://meta.discourse.org/t/ordering-categories-is-quite-glitched-when-the-numbers-get-high/367677/2 "2025-05-27T19:50:00Z")

</div>

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.

```plaintext
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
   subs_sorted.each do |sub|
      sub.update(position: pos)
      pos += 10
   end
end

```

---

_[View the full topic](https://meta.discourse.org/t/ordering-categories-is-quite-glitched-when-the-numbers-get-high/367677)._
