Skip to content
Tcl Source Code History Of Ticket 1f4bb8162fc33381
Login

History Of Ticket 1f4bb8162fc33381

Artifacts Associated With Ticket 1f4bb8162fc33381

  1. Ticket change [42ea7c04fd] (rid 151573) by fvogel on 2017-01-19 22:37:08:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      It is not obvious from the man page of [lsort] that when using -dictionary, the -nocase option is overriden. It can be understood by readong the manual for -nocase in the [lsort] page, but this could be improved.
      
      Example script showing what [lsort -dictionary] does:
      
      <verbatim>
        # ls.tcl --
        #     Multiple sorts with -dictionary
        #
        set list {{C c 1} {A B 2} {A b 3} {B b 4} {B a 5} {b a 6} {C c 7} {C a 8}}
      
        #
        # Sort by the second element:
        #
        set list2 [lsort -dictionary -index 1 $list]
      
        #
        # Sort by the first element:
        #
        set list3 [lsort -dictionary -index 0 $list2]
      
        #
        # Result:
        puts "Original:                    $list"
        puts "Sorted by second element:    $list2"
        puts "Sorted by first element:     $list3"
        puts "Expected:                    {A B  } {A b  } {B a  } {b a  } {B b  } {C a  } {C c  } {C c  }"
        puts "Expected (case sensitive):   {A B 2} {A b 3} {B a 5} {B b 4} {b a 6} {C a 8} {C c 1} {C c 7}"
        puts "Expected (case insensitive): {A B 2} {A b 3} {B a 5} {b a 6} {B b 4} {C a 8} {C c 1} {C c 7}"
      
        if {0} {
      
        How I arrived at each 'expected' ordering.  Col #1 is after sorting by
        #index 0, Col 2 is after sorting ties in index 0 by index 1
      
        Case sensitive:
        Initial | Col #1  | Col #2
        {C c 1}   {A B 2}   {A B 2}
        {A B 2}   {A b 3}   {A b 3}
        {A b 3}   {B b 4}   {B a 5}
        {B b 4}   {B a 5}   {B b 4}
        {B a 5}   {b a 6}   {b a 6}
        {b a 6}   {C c 1}   {C a 8}
        {C c 7}   {C c 7}   {C c 1}
        {C a 8}   {C a 8}   {C c 7}
      
        Case insensitive:
        Initial | Col #1  | Col #2
        {C c 1}   {A B 2}   {A B 2}
        {A B 2}   {A b 3}   {A b 3}
        {A b 3}   {B b 4}   {B a 5}
        {B b 4}   {B a 5}   {b a 6}
        {B a 5}   {b a 6}   {B b 4}
        {b a 6}   {C c 1}   {C a 8}
        {C c 7}   {C c 7}   {C c 1}
        {C a 8}   {C a 8}   {C c 7}
      
        }
      </verbatim>
      
      Running this one gets:
      
      <verbatim>
      $ tclsh ls.tcl
      Original:                    {C c 1} {A B 2} {A b 3} {B b 4} {B a 5} {b a 6} {C c 7} {C a 8}
      Sorted by second element:    {B a 5} {b a 6} {C a 8} {A B 2} {A b 3} {B b 4} {C c 1} {C c 7}
      Sorted by first element:     {A B 2} {A b 3} {B a 5} {B b 4} {b a 6} {C a 8} {C c 1} {C c 7}
      Expected:                    {A B  } {A b  } {B a  } {b a  } {B b  } {C a  } {C c  } {C c  }
      Expected (case sensitive):   {A B 2} {A b 3} {B a 5} {B b 4} {b a 6} {C a 8} {C c 1} {C c 7}
      Expected (case insensitive): {A B 2} {A b 3} {B a 5} {b a 6} {B b 4} {C a 8} {C c 1} {C c 7}
      </verbatim>
      
      The output from [lsort -dictionary] matches the expected 'case INsensitive' stable sorting of the elements by hand. Which also matches the man page that "-nocase" is ignored in "-dictionary" mode and that "-dictionary" uses
      case as a tie breaker only.
      
      However that could be made clearer in the man page by adding "Overrides the -nocase option." in the -dictionary option description.
      
      This was discussed in [https://groups.google.com/d/msg/comp.lang.tcl/ezPQszQG9-A/5m4webPbAgAJ|comp.lang.tcl]
      
    5. foundin initialized to: "core-8-6-branch"
    6. is_private initialized to: "0"
    7. login: "fvogel"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "a013af67114eccc19ad12b04f14923acea9e96b7"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "fvogel"
    14. subsystem initialized to: "17. Commands I-L"
    15. title initialized to: "lsort -dictionary: documentation to be improved"
    16. type initialized to: "Bug"
  2. Ticket change [97cc4099af] (rid 151577) by fvogel on 2017-01-19 22:40:21:

    1. assignee changed to: "fvogel"
    2. closedate changed to: "2457773.44469382"
    3. closer changed to: "fvogel"
    4. icomment:
      Fixed today, directly in core-8-6-branch and trunk.
      
    5. login: "fvogel"
    6. mimetype: "text/plain"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"
  3. Ticket change [62e1b62bf3] (rid 151578) by fvogel on 2017-01-19 22:47:27:

    1. closedate changed to: "2457773.44962713"
    2. comment changed to:
      It is not obvious from the man page of [lsort] that when using -dictionary, the -nocase option is overriden. It can be understood by readong the manual for -nocase in the [lsort] page, but this could be improved.
      
      Example script showing what [lsort -dictionary] does:
      
      <verbatim>
        # ls.tcl --
        #     Multiple sorts with -dictionary
        #
        set list {{C c 1} {A B 2} {A b 3} {B b 4} {B a 5} {b a 6} {C c 7} {C a 8}}
      
        #
        # Sort by the second element:
        #
        set list2 [lsort -dictionary -index 1 $list]
      
        #
        # Sort by the first element:
        #
        set list3 [lsort -dictionary -index 0 $list2]
      
        #
        # Result:
        puts "Original:                    $list"
        puts "Sorted by second element:    $list2"
        puts "Sorted by first element:     $list3"
        puts "Expected:                    {A B  } {A b  } {B a  } {b a  } {B b  } {C a  } {C c  } {C c  }"
        puts "Expected (case sensitive):   {A B 2} {A b 3} {B a 5} {B b 4} {b a 6} {C a 8} {C c 1} {C c 7}"
        puts "Expected (case insensitive): {A B 2} {A b 3} {B a 5} {b a 6} {B b 4} {C a 8} {C c 1} {C c 7}"
      
        if {0} {
      
        How I arrived at each 'expected' ordering.  Col #1 is after sorting by
        #index 0, Col 2 is after sorting ties in index 0 by index 1
      
        Case sensitive:
        Initial | Col #1  | Col #2
        {C c 1}   {A B 2}   {A B 2}
        {A B 2}   {A b 3}   {A b 3}
        {A b 3}   {B b 4}   {B a 5}
        {B b 4}   {B a 5}   {B b 4}
        {B a 5}   {b a 6}   {b a 6}
        {b a 6}   {C c 1}   {C a 8}
        {C c 7}   {C c 7}   {C c 1}
        {C a 8}   {C a 8}   {C c 7}
      
        Case insensitive:
        Initial | Col #1  | Col #2
        {C c 1}   {A B 2}   {A B 2}
        {A B 2}   {A b 3}   {A b 3}
        {A b 3}   {B b 4}   {B a 5}
        {B b 4}   {B a 5}   {b a 6}
        {B a 5}   {b a 6}   {B b 4}
        {b a 6}   {C c 1}   {C a 8}
        {C c 7}   {C c 7}   {C c 1}
        {C a 8}   {C a 8}   {C c 7}
      
        }
      </verbatim>
      
      Running this one gets:
      
      <verbatim>
      $ tclsh ls.tcl
      Original:                    {C c 1} {A B 2} {A b 3} {B b 4} {B a 5} {b a 6} {C c 7} {C a 8}
      Sorted by second element:    {B a 5} {b a 6} {C a 8} {A B 2} {A b 3} {B b 4} {C c 1} {C c 7}
      Sorted by first element:     {A B 2} {A b 3} {B a 5} {B b 4} {b a 6} {C a 8} {C c 1} {C c 7}
      Expected:                    {A B  } {A b  } {B a  } {b a  } {B b  } {C a  } {C c  } {C c  }
      Expected (case sensitive):   {A B 2} {A b 3} {B a 5} {B b 4} {b a 6} {C a 8} {C c 1} {C c 7}
      Expected (case insensitive): {A B 2} {A b 3} {B a 5} {b a 6} {B b 4} {C a 8} {C c 1} {C c 7}
      </verbatim>
      
      The output from [lsort -dictionary] matches the expected 'case sensitive' stable sorting of the elements by hand. Which also matches the man page that "-nocase" is ignored in "-dictionary" mode and that "-dictionary" uses
      case as a tie breaker only.
      
      However that could be made clearer in the man page by adding "Overrides the -nocase option." in the -dictionary option description.
      
      This was discussed in [https://groups.google.com/d/msg/comp.lang.tcl/ezPQszQG9-A/5m4webPbAgAJ|comp.lang.tcl]
      
    3. login: "fvogel"
    4. mimetype: "text/plain"