anchor.diff:                  true -> atom_to_list(Sort);
                   false -> Sort
               end,
  -    [FirstChar|F1] = Sort1,
  -    Order = case FirstChar of
  -                $- -> F1 ++ " DESC";
  -                $+ -> F1 ++ " ASC";
  -                _ -> Sort1 ++ " ASC"
  -            end,
  -    parse_query(Rest, Context, add_order(Order, Result));
  +    parse_query(Rest, Context, add_order(Sort1, Result));
   
   %% custompivot=tablename
   %% Add a join on the given custom pivot table.
  
positive.code:                         tables=[{rsc, "rsc"}]},
      R = parse_query(Query, Context, Start),
      %% add default sorting
      add_order("rsc.id desc", R).
  
  
  parse_request_args(Args) ->
  
negative.code: add_custompivot_join(Table, SearchSql) ->
      add_custompivot_join("rsc", Table, SearchSql).
  add_custompivot_join(RscTable, Table, Search) ->
      Table1 = sql_safe(Table),
      RscTable1 = sql_safe(RscTable),
      Alias = "pivot" ++ integer_to_list(length(Search#search_sql.tables)),
      JoinClause = "(" ++ RscTable1 ++ ".id = " ++ Alias ++ ".id)",
      Search#search_sql{
        tables=Search#search_sql.tables ++ [{Table, Alias}],
        from=Search#search_sql.from ++ " left join pivot_" ++ Table1 ++ " " ++ Alias ++ " on " ++ JoinClause
       }.
  
  %% Add an AND clause to the WHERE of a #search_sql
  %% Clause is already supposed to be safe.
  add_where(Clause, Search) ->
      case Search#search_sql.where of
          [] ->
  