anchor.diff:                  element(Ci,element(Ti,X))
           end
       end;
  +sort_fun(number,Ti,Ci,<<"desc">>) ->
  +    fun(X) -> 
  +        V = element(Ci,element(Ti,X)),
  +        case is_number(V) of
  +            true ->         (-V);
  +            false ->        element(Ci,element(Ti,X))
  +        end 
  +    end;
   sort_fun(string,Ti,Ci,<<"desc">>) -> 
       fun(X) -> 
           case element(Ci,element(Ti,X)) of 
  
positive.code:                 element(Ci,element(Ti,X))
          end 
      end;
  sort_fun(timestamp,Ti,Ci,<<"desc">>) -> 
      fun(X) -> 
          case element(Ci,element(Ti,X)) of 
              {Meg,Sec,Micro} when is_integer(Meg), is_integer(Sec), is_integer(Micro)->
                  {-Meg,-Sec,-Micro};
              _ ->
                  element(Ci,element(Ti,X))
          end    
      end;
  sort_fun(ipadr,Ti,Ci,<<"desc">>) -> 
      fun(X) -> 
          case element(Ci,element(Ti,X)) of 
  
negative.code:             ?ClientError({"Bad sort field", Else})
      end.
  
  sort_fun(atom,Ti,Ci,<<"desc">>) -> 
      fun(X) -> 
          case element(Ci,element(Ti,X)) of 
              A when is_atom(A) ->
                  [ -Item || Item <- atom_to_list(A)] ++ [?MaxChar];
              _ ->
                  element(Ci,element(Ti,X))
          end
      end;
  sort_fun(binstr,Ti,Ci,<<"desc">>) -> 
      fun(X) -> 
          case element(Ci,element(Ti,X)) of 
              B when is_binary(B) ->
                  [ -Item || Item <- binary_to_list(B)] ++ [?MaxChar];
              _ ->
                  element(Ci,element(Ti,X))
          end
      end;
  sort_fun(boolean,Ti,Ci,<<"desc">>) ->
      fun(X) -> 
          V = element(Ci,element(Ti,X)),
          case V of
              true ->         false;
              false ->        true;
              _ ->            element(Ci,element(Ti,X))
          end 
      end;
  sort_fun(datetime,Ti,Ci,<<"desc">>) -> 
  