Skip to content

Instantly share code, notes, and snippets.

@think2011
Created January 16, 2017 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save think2011/a9249b503094b4c69dfb8f534abdc87f to your computer and use it in GitHub Desktop.
Save think2011/a9249b503094b4c69dfb8f534abdc87f to your computer and use it in GitHub Desktop.
合并和排序
var a = [1, 2, 45, 88];
var b = [3, 7, 8];
var flag = 0;
for (let i = 0; i < b.length; i++) {
if (b[i] <= a[flag] || flag > a.length) {
a.splice(flag, 0, b[i]);
} else {
i--;
}
flag++;
}
console.log(a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment