magicalpanda/MagicalRecord — pull request #255 by felipesabino (2012-09-18 00:36:45+00:00)
Title: added specific column sort ability to fetch methods

I spent some time dealing with the fetch methods sorting implementation to be able to sort one column ascending and another one descending and found out that I could not do this without changing MagicalRecord fetch code itself.

The current implementation uses the sorting *NSString* and splits it by comas to create a *NSSortDescriptor* for each column, using the *ascending* flag for all of them, so all columns would have the same sort order.

I don't know a better way to change the fetch methods implementation without breaking everything else, so while trying to change as little as possible and also keeping backwards compatibility, I added the *ASC* and *DESC* check for each column sent as sort key, then I change its sort order accordingly, ignoring the *ascending* flag if it matches an *ASC* or *DESC* string in the end of the column name.

So, you could pass @"column1,column2 DESC" as *sortTerm* , which would make *column2* to have a descent order when performing the fetch, regardless of the *ascending* flag value passed to the fetch request.