www.webdeveloper.com
Results 1 to 3 of 3

Thread: Sort with JQuery

  1. #1
    Join Date
    Nov 2010
    Posts
    78

    Sort with JQuery

    I can't find any syntax for how to sort something with JQuery but here's a description of what I'm wanting to do.


    1. Start with the list of matches, in order. Introduction comes first.
    2. Sort the segments by segmentOrder first, segmentNum second.
    3. Insert each segment after match #(segmentOrder), in the same order.

    Code:
    Introduction: type=M, m=I,            n=0
    Matches:      type=M, m=match number, n=0
    Segments:     type=S, m=segmentOrder, n=segmentNum
    
    Sort:
    1. m (ascending; I first)
    2. type (M first, S second)
    3. n (ascending)
    
    
    Before                 After
    --------------------   --------------------
    I:  type=M, m=I, n=0   I:  type=M, m=I, n=0
    M1: type=M, m=1, n=0   S1: type=S, m=I, n=1
    M2: type=M, m=2, n=0   M1: type=M, m=1, n=0
    M3: type=M, m=3, n=0   S2: type=S, m=1, n=2
    M4: type=M, m=4, n=0   S3: type=S, m=1, n=3
    M5: type=M, m=5, n=0   M2: type=M, m=2, n=0
    M6: type=M, m=6, n=0   M3: type=M, m=3, n=0
    M7: type=M, m=7, n=0   S4: type=S, m=3, n=4
    S1: type=S, m=I, n=1   M4: type=M, m=4, n=0
    S2: type=S, m=1, n=2   M5: type=M, m=5, n=0
    S3: type=S, m=1, n=3   M6: type=M, m=6, n=0
    S4: type=S, m=3, n=4   S5: type=S, m=6, n=5
    S5: type=S, m=6, n=5   M7: type=M, m=7, n=0
    Here's my actual code.

    http://pastebin.com/5LuQTuNH
    Last edited by xtremer360; 04-28-2011 at 10:30 AM.

  2. #2
    Join Date
    Nov 2010
    Posts
    78
    Any ideas?

  3. #3
    Join Date
    Apr 2011
    Location
    Missouri
    Posts
    83
    jQuery doesn't currently contain a sort method.

    You will have to use native JavaScript's sort method: http://www.w3schools.com/jsref/jsref_sort.asp.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles