1

Let's say I have a collection products with the following values for "name":

  • Awesome sneakers
  • Boring Umbrella
  • 420 product

The following code:

@products.reorder('name ASC') # I really need to use reorder in my code

will list the results as-is:

  • 420 product
  • Awesome sneakers
  • Boring Umbrella

What should I tweak in reorder() to have the following order:

  • Awesome sneakers
  • Boring Umbrella
  • 420 product
Jeremie Ges
  • 2,653
  • 2
  • 19
  • 36

2 Answers2

1
@products.reorder("(name ~ '^[0-9]'), name")

Explanation: FALSE sorts before TRUE so digit values will be last.

Alex Baidan
  • 935
  • 6
  • 15
0
@products.reorder("(name !~* '^[a-z]'), name")
codenamev
  • 2,023
  • 16
  • 23