Search code examples
sortingcrystal-reportsmodulo

Sort even numbers, then odd numbers


I need to sort street addresses for people to walk on either side of the street. Therefore I need to order the even address numbers first, then the odd numbers.

I've already managed to sort by street name, but now how do I sort the data by evens and then odds within the streets?


Solution

  • Make a new formula called EvenOrOdd:

    ToNumber({addressNumber}) MOD 2
    

    This returns 0 when a number is even, and 1 when a number is odd. Then add a new Group inside your existing group and sort based on EvenOrOdd.