Updated MR_requestAllSortedBy methods to handle '+'/'-' flags embedded in the comma-separated sortTerm string for attribute-specific ascending/descending #181

Closed
wants to merge 1 commit into from

3 participants

@jlenorovitz

...n the comma-separated sortTerm string for attribute-specific ascending/descending

The sortTerm string (which could already accept a comma-separated list of attributes) can now parse '+' and '-' characters (optionally) prepended to each attribute so that the sort can be ascending by some attributes and descending by others.

Notes:

  • The method-level 'ascending' BOOL argument still has effect as the master, making the '+'/'-' flags relative to the master sort order
  • The '+' is strictly optional as ascending is the default if no flag is used
  • All legacy behavior of these methods is preserved

EXAMPLE:
sortTerm: @"-golfScore,lastName,+firstName"
would return results sorted first by descending golfScore, then ascending lastName, then ascending firstName

If the method-level 'ascending' BOOL were passed as NO then the sort order would be ascending by golfScore, then descending by lastName, then descending by firstName

Signed-off-by: Joel Lenorovitz joel@mobileXware.com

@jlenorovitz jlenorovitz Updated MR_requestAllSortedBy methods to handle '+'/'-' flags embedde…
…d in the comma-separated sortTerm string for attribute-specific ascending/descending

The sortTerm string (which could already accept a comma-separated list of attributes) can now parse '+' and '-' characters (optionally) prepended to each attribute so that the sort can be ascending by some attributes and descending by others.

Notes:
- The method-level 'ascending' BOOL argument still has effect as the master, making the '+'/'-' flags relative to the master sort order
- The '+' is strictly optional as ascending is the default if no flag is used
- All legacy behavior of these methods is preserved

EXAMPLE:
	sortTerm: @"-golfScore,lastName,+firstName"
would return results sorted first by descending golfScore, then ascending lastName, then ascending firstName

If the method-level 'ascending' BOOL were passed as NO then the sort order would be ascending by golfScore, then descending by lastName, then descending by firstName

Signed-off-by: Joel Lenorovitz <joel@mobileXware.com>
6c75aef
@blackgold9
Magical Panda Software member

While this seems like it works, it adds another layer of complexity that I'd like to avoid.

@blackgold9 blackgold9 closed this Sep 16, 2012
@jlenorovitz
@blackgold9
Magical Panda Software member

Sounds good. This is Saul's baby, and if he's ok with it, then so am I.

@blackgold9 blackgold9 reopened this Oct 15, 2012
@blackgold9
Magical Panda Software member

Can you add unit tests for this?

@casademora
Magical Panda Software member
@blackgold9
Magical Panda Software member

Merged a cleaner, more recent implementation

@blackgold9 blackgold9 closed this Jul 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment