teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

テキスト修正

2019/11/13 09:08

投稿

jun68ykt
jun68ykt

スコア9058

answer CHANGED
@@ -10,4 +10,17 @@
10
10
  return a - b;
11
11
  }
12
12
  ```
13
- - **動作確認用 CodePen:** [https://codepen.io/jun68ykt/pen/pooOZbR?editors=0012](https://codepen.io/jun68ykt/pen/pooOZbR?editors=0012)
13
+ - **動作確認用 CodePen:** [https://codepen.io/jun68ykt/pen/pooOZbR?editors=0012](https://codepen.io/jun68ykt/pen/pooOZbR?editors=0012)
14
+
15
+ ### 追記
16
+
17
+ 別の方法を挙げます。(与えられた配列を `data` とします。)
18
+
19
+ ```
20
+ [
21
+ ...data.filter(e => e === 3),
22
+ ...data.filter(e => e !== 3).sort((a,b) => a - b)
23
+ ]
24
+ ```
25
+
26
+ - **動作確認用CodePen:** [https://codepen.io/jun68ykt/pen/QWWVZEP?editors=0012](https://codepen.io/jun68ykt/pen/QWWVZEP?editors=0012)