Iñigo
Iñigo

Reputation: 12823

Vim: sort command's algorithm

Does anyone know which algorithm is used internally on Vim when :sort command is used?
Is the same algorithm used to sort 10 lines than the one used to sort 10000 lines?

Upvotes: 2

Views: 342

Answers (2)

romainl
romainl

Reputation: 196781

When available, an external sort program is used. The internal algorithm is undocumented.

edit

Well, "undocumented as in ":help :sort doesn't explain how the internal algo works".

Upvotes: 0

Ingo Karkat
Ingo Karkat

Reputation: 172688

Vim is open source; why don't you just have a look yourself? It's easiest via the online Mercurial repository:

http://code.google.com/p/vim/source/browse/src/ex_cmds.c

Vim delegates the actual sorting to the qsort() library function.

Upvotes: 4

Related Questions