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