sort by plus cards

Ticket

+commit
 
Makes a big difference to be able to sort by more than one (e.g. +last name, +first name).

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

 

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.

 

 

need to work on docs for this.  above examples are not entirely correct.  here's one eg from tests:

 

Wql.new( :right_plus=>'*table of contents', :sort=>{ :right=>'*table_of_contents'}, :sort_as=>'integer'  )


Given example works - http://test.dwagn.org/wagn/sorting_by_toc

 

I see this allow for searching on things other than "right", such as "count", if you give some current-syntax ruby examples I'll probably test those too...

  --John Abbe.....Tue Nov 29 19:44:21 -0800 2011


Did this ever get documented, and if so where? Not seeing it on CQL Syntax. (or +not ready)

  --John Abbe.....2013-03-18 04:19:40 +0000