Loading ...
Sorry, an error occurred while loading the content.
 

Re: Feature request: sort()

Expand Messages
  • Michael Brailsford
    ... There are several ways around this. One of which Benji Fisher already mentioned. Another is that you can script vim with ruby, python or perl. Each of
    Message 1 of 7 , Dec 5, 2002
      > Would it be a great effort to add a built-in sort() function to Vim?
      > In cases where a large list needs to be sorted, the speed of script is
      > no match for C. I would envision something like:

      There are several ways around this. One of which Benji Fisher already
      mentioned. Another is that you can script vim with ruby, python
      or perl. Each of those langauges is cross-platform and they each
      have a sort method. It wouldn't be too difficult to write a wrapper
      vim function that simply calls a sort method in one of those languages.

      -Michael
    • Piet Delport
      ... Agreed, but consider that Vim already has things like hostname(), input*(), char2nr() tolower()/toupper(), and more. Vim is a text editor, and sorting
      Message 2 of 7 , Dec 5, 2002
        On Wed, 04 Dec 2002 at 09:46:17 -0500, Benji Fisher wrote:
        > digitect@... wrote:
        >> Would it be a great effort to add a built-in sort() function to Vim?
        >> In cases where a large list needs to be sorted, the speed of script is
        >> no match for C. I would envision something like:
        >
        > I agree that sorting is important, but I think that including this
        > would be a step in the direction of Vim-OS, so it is unlikely to happen.
        >
        > :help design-not
        >
        > It should be possible to write a vim script that looks for an external
        > sort program and defines Sort() as a wrapper for it, or else implements
        > Sort() in vim script.

        Agreed, but consider that Vim already has things like hostname(),
        input*(), char2nr() tolower()/toupper(), and more. Vim is a text
        editor, and sorting text is a pretty fundamental part of text editing,
        compared to something like getting the machine's hostname.

        I don't think that a sorting function is a step in the Vim-OS direction
        at all, and would welcome one. One more argument for it (besides it
        enhancing Vim's usefulness on platforms that lack external sort
        programs) is that an internal sort function could take advantage of
        Vim's existing character set and multibyte code, to support correct
        collating.

        Along with a sort function, another useful thing would be a simple :sort
        command that takes a range and sorts it. It would fit right in with the
        likes of :right, :center and :left, IMHO.

        --
        Piet Delport
        Today's subliminal thought is:
      • Tommy Reynolds
        ... Well, sort isn t a O/S level issue: it s a C language issue. VIM is rather closely bound to C already so a call to the standard C library routine
        Message 3 of 7 , Dec 5, 2002
          Overcoming an impressive lethargy, Piet Delport <pjd@...> scribbled:

          > On Wed, 04 Dec 2002 at 09:46:17 -0500, Benji Fisher wrote:
          > > digitect@... wrote:
          > >> Would it be a great effort to add a built-in sort() function to Vim?
          > > I agree that sorting is important, but I think that including this
          > > would be a step in the direction of Vim-OS, so it is unlikely to happen.
          > >
          > > It should be possible to write a vim script that looks for an external
          > > sort program and defines Sort() as a wrapper for it, or else implements
          > > Sort() in vim script.
          >
          > Agreed, but consider that Vim already has things like hostname(),
          > input*(), char2nr() tolower()/toupper(), and more. Vim is a text
          > editor, and sorting text is a pretty fundamental part of text editing,
          > compared to something like getting the machine's hostname.

          Well, "sort" isn't a O/S level issue: it's a C language issue.
          VIM is rather closely bound to C already so a call to the standard C
          library routine "qsort(3)" isn't likely to be unportable: it should be
          part of the standard libary. If not, providing a work-alike is
          simple since qsort(3) has been repeatedly ported and re-ported and
          re-implemented almost since time began ;-)
        • digitect@mindspring.com
          ... [arguments for and against] Thanks for the discussion. A few final points from me... * External !SORT in my instance is too bothersome because of the
          Message 4 of 7 , Dec 6, 2002
            >>>digitect@... wrote:
            >>>>
            >>>>Would it be a great effort to add a built-in sort() function to Vim?

            [arguments for and against]

            Thanks for the discussion. A few final points from me...

            * External !SORT in my instance is too bothersome because of the
            terminal window that is raised by gVim.

            * Perl, ruby, python... nice, but require these installed, which is
            hidden bloat anyway. I can't count on this. (That's what I meant by
            overhead, not speed--sorry for not being clear.)

            I'm trying to build an abstracted heirarchical tree display method,
            with content abstracted from display and indented, multiple nodes open
            at a time. I need the speed (depending on the application) for column
            sorts with large data sets without the above restraints.


            Steve Hall [ digitect(at)mindspring.com ]
          Your message has been successfully submitted and would be delivered to recipients shortly.