DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
    • can-component
    • can-compute
    • can-connect
    • can-define
    • can-define/list/list
    • can-define/map/map
    • can-route
    • can-route-pushstate
    • can-set
      • types
        • Set
        • Compares
        • Prop
      • properties
        • Algebra
        • Translate
        • props
          • boolean
          • enum
          • id
          • offsetLimit
          • rangeInclusive
          • sort
    • can-stache
    • can-stache/helpers/route
    • can-stache-bindings
  • Ecosystem
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Core
  • /
  • can-set
  • /
  • props
  • /
  • sort
  • / On this page
    • sort

      function

      Defines the sortable property and behavior.

      • source

      set.props.sort(prop, [sortFunc])

      Defines the sortable property and behavior.

      var algebra = new set.Algebra(set.props.sort("sortBy"));
      algebra.index(
        {sortBy: "name desc"},
        [{name: "Meyer"}],
        {name: "Adams"}) //-> 1
      
      algebra.index(
        {sortBy: "name"},
        [{name: "Meyer"}],
        {name: "Adams"}) //-> 0
      

      Parameters

      1. prop {String}:

        The sortable property.

      2. sortFunc {function(sortPropValue, item1, item2)}:

        The sortable behavior. The default behavior assumes the sort property value looks like PROPERTY DIRECTION (ex: name desc).

      Returns

      {Compares}:

      Returns a compares that can be used to create a set.Algebra.

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.