Skip to content
Tcl Source Code History Of Ticket 2082681fffffffff
Login

History Of Ticket 2082681fffffffff

Artifacts Associated With Ticket 2082681fffffffff

  1. Ticket change [0958e1859c] (rid 89708) by kieranelby on 2008-08-29 16:10:14:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      This is a patch to add a "-group grpSize" option to lsort to cause
      it to treat the list as consisting of groups of grpSize elements,
      and to then perform the sort group-wise, keeping the elements within
      each group together.
      
      This is similar to what was requested in Feature Request 747083:
      
      https://sourceforge.net/tracker/index.php?func=detail&aid=747083&group_id=10894&atid=360894
      
      A more detailed explanation follows (not quite a TIP yet tho!).
      
      As well as the code change, the patch includes a change to the man page,
      but I've not included any test suite changes (are there any existing tests for lsort?).
      
      Rationale
      =========
      
      "Flat" name-value pair lists are ubiquitous in Tcl - consider the
      output of "array get", "dict create" or the input to "foreach".
      
      It is surprising then that there is no command to directly sort
      such a list by either the name or the value elements, while
      preserving the name-value mapping.
      
      Doing so currently requires turning a name-value pair list into
      a list of sublists, using the lsort -index option to sort them,
      then flattening the list again, which is rather fiddly and
      inefficient.
      
      With this proposal, sorting a name-value pair list by the names is
      achieved with "lsort -group 2 $myList".
      
      Specification
      =============
      
      A new option, "-group", taking one parameter, "grpSize" will be
      added to the lsort command.
      
      If -group is supplied, the list will be treated as consisting of
      groups of grpSize elements, and the groups will be sorted by either
      their first element or, if the -index option is used, by the element
      within each group given by the first index passed to -index (which
      is then ignored by -index).
      
      Elements always remain in the same position within their group.
      
      The list length must be a multiple of grpSize, which in turn must be
      at least 2.
      
      Examples
      ========
      
      | lsort -group 2 {carrot 10 apple 50 banana 25}
      returns {apple 50 banana 25 carrot 10}
      
      | lsort -group 2 -index 1 -integer {carrot 10 apple 50 banana 25}
      returns {carrot 10 banana 25 apple 50}
      
      | lsort -group 3 -index {0 1} {{Bob Smith} 25 Audi {Jane Doe} 40 Ford}
      return {{Jane Doe} 40 Ford {Bob Smith} 25 Audi}
      (since Smith, which is at index 1 of element 0 of the first group comes
      after Doe, which is at the same position in the next group of 3.)
      
      Limitations
      ===========
      
      Only one element in each group can be used for comparison.
      
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "kieranelby"
    10. subsystem initialized to: "17. Commands I-L"
    11. title initialized to: "Add -group option to lsort"
    12. type initialized to: "Patch"
  2. Ticket change [ef22b55599] (rid 108940) by kieranelby on 2008-08-29 23:10:14:

    1. icomment:
      
      
      File Added - 291304: grouping_lsort.patch
      
      
      
    2. login: "kieranelby"
    3. mimetype: "text/plain"
    4. username: "kieranelby"
  3. Ticket change [7196de3ea3] (rid 100711) by kieranelby on 2008-09-01 22:38:11:

    1. icomment:
      
      
      File Deleted - 291304: 
      
      
      
      File Added - 291638: grouping_lsort.patch
      
      Logged In: YES 
      user_id=99072
      Originator: YES
      
      File Added: grouping_lsort.patch
      
      
    2. login: "kieranelby"
    3. mimetype: "text/plain"
    4. username: "kieranelby"
  4. Add attachment "grouping_lsort.patch" [8079d0a006] (rid 116876) by kieranelby on 2008-09-01 22:38:11.

  5. Ticket change [5c7d743e16] (rid 115307) by dkf on 2008-09-25 19:16:40:

    1. foundin changed to: "TIP Implementation"
    2. priority changed to: "9 Immediate"
  6. Ticket change [0b2369ae8f] (rid 113930) by dkf on 2008-09-29 15:51:57:

    1. title changed to: "TIP #326: Add -group option to lsort"
  7. Ticket change [488c5d551c] (rid 99904) by dkf on 2008-09-29 20:39:11:

    1. closedate changed to: "2008-09-29T13:39:11"
    2. closer changed to: "dkf"
    3. icomment:
      Accepted with modifications and addition of (simple) tests.
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. resolution changed to: "Accepted"
    7. status changed to: "Closed"
    8. username: "dkf"