> > We need to escape string to avoid to handle index as value.
> I don't think so.
> > I don't want to need to provide this function in all plugins. Just
> > want to get it in official sort function.
> The reason is:
>     :echo sort(['3 0', '3 0 1'])
>     ['3 0 1', '3 0']
> I'd expect ['3 0', '3 0 1'].
>     :echo '3 0' < '3 0 1'
>     1
> Bug in sort() function?

See :help sort()

> The sort is stable, items which compare equal (as number or as
> string) will keep their relative position. E.g., when sorting
> on numbers, text strings will sort next to each other, in the
> same order as they were originally.

It need to do like below with MapSort()

echo MapSort([{"foo":{"bar": "3"}}, {"foo":{"bar": "3 0"}}], '0 + 
v:val["foo"]["bar"]')

If using my patch, it is possible easy to avoid this.

:echo sort(["3 0", "3 0 1"], "a:lhs < a:rhs")

And MapSort() can't look local variable in the expression. For example, this 
doesn't work.

---------------------------------------------------
function! s:foo()
  let rank = {"queen": 12, "king": 13}
  return MapSort(["queen", "king"], 'rank[v:val]')
endfunction
echo s:foo()
---------------------------------------------------

But:

---------------------------------------------------
function! s:foo()
  let rank = {"queen": 12, "king": 13}
  return sort(["queen", "king"], 'rank[v:lhs] < rank[v:rhs]')
endfunction
echo s:foo()
---------------------------------------------------

This should be worked.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui