sort by plus cards
Ticket
+issues
Before doing this, it might be worth considering an even more powerful/general approach to sorting. Imagine each User has a Pointer to their high school, each of which has an address, then i'd like to be able to sort a bunch of Users by their high school's city. Again, sorting by more than one is much better (country, state/province, city).
Also see:
view (line) not supported for sort by content
+solution
sort should be able to take a hash.
Here's the ruby long form for a plus card sort to sort Call cards by the content of a +call number card:
{ type: 'Call',
sort:{
:right=>'call_number',
:left=>'_item', # this means the result item is the left part of the sort card. # this is the hard part, because it requires special handling based on the value # this probably has to be the value of a root-level key, and may only work for a limited set.
:return=>'content' # this should probably be the default for anything with a cardspec
:cast =>'integer' # this means sort the content as numbers (1,2,3), not strings (1,10,100). Strings is default for 'content'
}
}
rough version of the sql that translates to:
Ruby long form for sorting territories based on the number of users in them (as represented by [user]+territory)
{ type: 'Territory',
sort:{
:left =>{:type=>'User'},
:right =>'Territory',
:return =>'count', #not sure "return" is right word here, but it parallels normal wql usage
:refer_to =>'_item'
},
:dir => 'desc'
}
and the sql:
You can also do variations on the current sort results. For example, to sort a list of cards by their content numerically, you can do this:
sort: { :return=> 'content', :cast=>'integer' }
As for having multiple sort variables, I think at this point that becomes comparatively simple -- you just give the sort argument an array. Eg
sort:
[ { :right=>'last name', :left=>'_item' },
{ :right=>'first name', :left=>'_item' }, 'update' ]
We may also want to add shortcuts for plus card sorts, like { :sort => '+last name' }, but the full syntax is important and will have to be deduced anyway, and the shortcut conversation would probably have other higher priorities.