lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Lorenzo Donati once stated:
> Thank you for the prompt reply!
> 
> On 09/04/2011 20.27, Luiz Henrique de Figueiredo wrote:
> >>I was wondering whether it would be sensible to modify the table.sort
> >>function so that it returns its first argument.
> >
> >table.sort does not return the table to avoid giving the impression that
> >it creates a new table. In other words, it stresses the point that the
> >sort in performed in place.
> >
> 
> 
> Mmmm. I see, but still I'm not truly convinced that it is worth the 
> inconvenience.

  It's easy enough to fix in stock Lua:

do
  local tablesort = table.sort
  function table.sort(t)
    tablesort(t)
    return t
  end
end

  -spc