Empty vectors work much better as the result of sorting an empty array
than nil does...
This commit is contained in:
+1
-1
@@ -514,7 +514,7 @@ static naRef f_sort(naContext c, naRef me, int argc, naRef* args)
|
|||||||
if(argc != 2 || !naIsVector(args[0]) || !naIsFunc(args[1]))
|
if(argc != 2 || !naIsVector(args[0]) || !naIsFunc(args[1]))
|
||||||
naRuntimeError(c, "bad/missing argument to sort()");
|
naRuntimeError(c, "bad/missing argument to sort()");
|
||||||
sd.subc = naSubContext(c);
|
sd.subc = naSubContext(c);
|
||||||
if(!PTR(args[0]).vec->rec) return naNil();
|
if(!PTR(args[0]).vec->rec) return naNewVector(c);
|
||||||
sd.elems = PTR(args[0]).vec->rec->array;
|
sd.elems = PTR(args[0]).vec->rec->array;
|
||||||
sd.n = PTR(args[0]).vec->rec->size;
|
sd.n = PTR(args[0]).vec->rec->size;
|
||||||
sd.fn = args[1];
|
sd.fn = args[1];
|
||||||
|
|||||||
Reference in New Issue
Block a user