B2G/gecko/browser/components/places/content/places.js
/**
   * Sorts the view by the specified column.
   * @param   aColumn
   *          The colum that is the sort key. Can be null - the
   *          current sort column or the title column will be used.
   * @param   aDirection
   *          The direction to sort - "ascending" or "descending".
   *          Can be null - the last direction or descending will be used.
   *
   * If both aColumnID and aDirection are null, the view will be unsorted.
   */
Sorts the view by the specified column.
@param   aColumn
The colum that is the sort key. Can be null - the
current sort column or the title column will be used.
@param   aDirection
The direction to sort - "ascending" or "descending".
Can be null - the last direction or descending will be used.

If both aColumnID and aDirection are null, the view will be unsorted.
Sorts the view by the specified column . @param aColumn The colum that is the sort key . Can be null - the current sort column or the title column will be used . @param aDirection The direction to sort - " ascending " or " descending " . Can be null - the last direction or descending will be used . If both aColumnID and aDirection are null the view will be unsorted .
function VM_setSortColumn(aColumn, aDirection) {
    var result = document.getElementById("placeContent").result;
    if (!aColumn && !aDirection) {
      result.sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_NONE;
      return;
    }
    var columnId;
    if (aColumn) {
      columnId = aColumn.getAttribute("anonid");
      if (!aDirection) {
        var sortColumn = this._getSortColumn();
        if (sortColumn)
          aDirection = sortColumn.getAttribute("sortDirection");
      }
    }
    else {
      var sortColumn = this._getSortColumn();
      columnId = sortColumn ? sortColumn.getAttribute("anonid") : "title";
    }
    var colLookupTable = {
      title:        { key: "TITLE",        dir: "ascending"  },
      tags:         { key: "TAGS",         dir: "ascending"  },
      url:          { key: "URI",          dir: "ascending"  },
      date:         { key: "DATE",         dir: "descending" },
      visitCount:   { key: "VISITCOUNT",   dir: "descending" },
      keyword:      { key: "KEYWORD",      dir: "ascending"  },
      dateAdded:    { key: "DATEADDED",    dir: "descending" },
      lastModified: { key: "LASTMODIFIED", dir: "descending" },
      description:  { key: "ANNOTATION",
                      dir: "ascending",
                      anno: PlacesUIUtils.DESCRIPTION_ANNO }
    };
    if (!colLookupTable.hasOwnProperty(columnId))
      throw("Invalid column");
    aDirection = (aDirection || colLookupTable[columnId].dir).toUpperCase();
    var sortConst = "SORT_BY_" + colLookupTable[columnId].key + "_" + aDirection;
    result.sortingAnnotation = colLookupTable[columnId].anno || "";
    result.sortingMode = Ci.nsINavHistoryQueryOptions[sortConst];
  }
function VM_setSortColumn ( aColumn , aDirection ) { var result = document . getElementById ( "placeContent" ) . result ; if ( ! aColumn && ! aDirection ) { result . sortingMode = Ci . nsINavHistoryQueryOptions . SORT_BY_NONE ; return ; } var columnId ; if ( aColumn ) { columnId = aColumn . getAttribute ( "anonid" ) ; if ( ! aDirection ) { var sortColumn = this . _getSortColumn ( ) ; if ( sortColumn ) aDirection = sortColumn . getAttribute ( "sortDirection" ) ; } } else { var sortColumn = this . _getSortColumn ( ) ; columnId = sortColumn ? sortColumn . getAttribute ( "anonid" ) : "title" ; } var colLookupTable = { title : { key : "TITLE" , dir : "ascending" } , tags : { key : "TAGS" , dir : "ascending" } , url : { key : "URI" , dir : "ascending" } , date : { key : "DATE" , dir : "descending" } , visitCount : { key : "VISITCOUNT" , dir : "descending" } , keyword : { key : "KEYWORD" , dir : "ascending" } , dateAdded : { key : "DATEADDED" , dir : "descending" } , lastModified : { key : "LASTMODIFIED" , dir : "descending" } , description : { key : "ANNOTATION" , dir : "ascending" , anno : PlacesUIUtils . DESCRIPTION_ANNO } } ; if ( ! colLookupTable . hasOwnProperty ( columnId ) ) throw ( "Invalid column" ) ; aDirection = ( aDirection || colLookupTable [ columnId ] . dir ) . toUpperCase ( ) ; var sortConst = "SORT_BY_" + colLookupTable [ columnId ] . key + "_" + aDirection ; result . sortingAnnotation = colLookupTable [ columnId ] . anno || "" ; result . sortingMode = Ci . nsINavHistoryQueryOptions [ sortConst ] ; }
Sorts the view by the specified column.
Sorts the view by the specified column .
// This maps the possible values of columnId (i.e., anonid's of treecols in // placeContent) to the default sortingMode and sortingAnnotation values for // each column. //   key:  Sort key in the name of one of the //         nsINavHistoryQueryOptions.SORT_BY_* constants //   dir:  Default sort direction to use if none has been specified //   anno: The annotation to sort by, if key is "ANNOTATION" // Make sure we have a valid column. // Use a default sort direction if none has been specified.  If aDirection // is invalid, result.sortingMode will be undefined, which has the effect // of unsorting the tree.