Browse Source

Merge pull request #256 from MStoykov/stableSort

Conform to ECMAScript 2019 by making the sort stable
Dmitry Panov 4 years ago
parent
commit
60bc6ebb9f
2 changed files with 2 additions and 2 deletions
  1. 1 1
      builtin_array.go
  2. 1 1
      builtin_typedarrays.go

+ 1 - 1
builtin_array.go

@@ -352,7 +352,7 @@ func (r *Runtime) arrayproto_sort(call FunctionCall) Value {
 		compare: compareFn,
 		compare: compareFn,
 	}
 	}
 
 
-	sort.Sort(&ctx)
+	sort.Stable(&ctx)
 	return o
 	return o
 }
 }
 
 

+ 1 - 1
builtin_typedarrays.go

@@ -973,7 +973,7 @@ func (r *Runtime) typedArrayProto_sort(call FunctionCall) Value {
 			compare: compareFn,
 			compare: compareFn,
 		}
 		}
 
 
-		sort.Sort(&ctx)
+		sort.Stable(&ctx)
 		return call.This
 		return call.This
 	}
 	}
 	panic(r.NewTypeError("Method TypedArray.prototype.sort called on incompatible receiver %s", call.This.String()))
 	panic(r.NewTypeError("Method TypedArray.prototype.sort called on incompatible receiver %s", call.This.String()))