Menu

Bug/CR: Text FX sort lines at column/position

2007-07-30
2012-11-13
  • Nobody/Anonymous

    It seems this sort function only looks at the character number/column instead of the shown position, as I would expect (or like).

    Currently, it does not help me when wanting to sort lines on data in a certain tabbed column:

    8    1
    -7    2
    --6    3
    ---5    4
    --4    5
    -3    6
    2    7
    -1    8

    There is a tab between the first and second numeric character. This should show two columns of data, the second showing the numbers 1 to 8.

    I select all lines, starting on the empty line under the "table", moving the cursor to the first line, just before the 1 (and after the tab character).
    Then I choose Text FX, sort lines case insensitive (at column).
    This is the result:

    -7    2
    -3    6
    -1    8
    ---5    4
    8    1
    --4    5
    --6    3
    2    7

    I would expect the lines no to change, that is, the order 1 to 8 in the second column to remain. But what I see puzzles me. It seems the data is sorted from the third character of each line. For the first three lines that is the tab character, followed by the numbers 2, 6 and 8. On line 4 it is the - sign. Line 5 has the 1 that I selected as the starting position. Lines 6 and 7 are ordered by the 4 and 6 respectively and finally there is the 7, just as the 1 on line 5.

    Is this a bug, or intentionally?
    If it is intentionally, will you think about a sort function on the _visible_ column/position, accounting for the number of spaces set for the tab character?

     
    • Nobody/Anonymous

      Because the forum converts the tab characters to single space characters, it may look like this way of sorting makes sense. All the characters I mentioned now really are at position 3 of each line, and these are in ascending order. But of course, I do _not_ have spaces in NP++ and the layout of these lines is different, in two straight columns.

       
    • Nobody/Anonymous

      How do I do that?
      Can I undo that after sorting?

      It would be much more convenient to have the sorting function account for the number of spaces that tab characters are intended to "replace". It wouldn't be too hard to implement this feature, practically the same as the code that shows the characters at their intended position because of the tab character and the number of spaces to the next tab stop it does reflect, as set.

       
    • Greg Bullock

      Greg Bullock - 2007-07-30

      > Is this a bug, or intentionally?

      It's not a bug, it's working as intended.  The term "column" (as in, sort at column) refers to character position, counting spaces and tabs each as a single character.

      As it stands, you'd first have to convert your tabs to the appropriate number of spaces before marking your column and sorting.

      Regards.
      Greg