blob: 3dba042a84f055e12a8d9575234bf2ae3a885184 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
---
title: URLSearchParams.sort()
slug: Web/API/URLSearchParams/sort
tags:
- API
- Method
- Reference
- URL API
- URLSearchParams
- sort
translation_of: Web/API/URLSearchParams/sort
---
<p>{{APIRef("URL API")}}</p>
<p><span class="seoSummary"><strong><code>URLSearchParams.sort()</code></strong> メソッドは、このオブジェクトに含まれるすべてのキー/値のペアをその場でソートし、<code>undefined</code> を返します。 ソート順は、キーの Unicode コードポイントに従っています。 このメソッドは、安定したソートアルゴリズムを使用します(つまり、等しいキーを持つキー/値のペア間の相対的な順序が保持されます)。</span></p>
<p>{{availableinworkers}}</p>
<h2 id="Syntax" name="Syntax">構文</h2>
<pre class="syntaxbox">searchParams.sort();</pre>
<h3 id="Parameters" name="Parameters">パラメーター</h3>
<p>なし。</p>
<h3 id="Return_value" name="Return_value">戻り値</h3>
<p><code>undefined</code>。</p>
<h2 id="Examples" name="Examples">例</h2>
<pre class="brush: js;highlight:[5]">// テスト用の URLSearchParams オブジェクトの作成
var searchParams = new URLSearchParams("c=4&a=2&b=3&a=1");
// キー/値のペアのソート
searchParams.sort();
// ソートされたクエリー文字列の表示
console.log(searchParams.toString());
</pre>
<p>結果は次のとおりです。</p>
<pre>a=2&a=1&b=3&c=4</pre>
<h2 id="Specifications" name="Specifications">仕様</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">仕様</th>
<th scope="col">状態</th>
<th scope="col">コメント</th>
</tr>
<tr>
<td>{{SpecName('URL', '#dom-urlsearchparams-sort','sort()')}}</td>
<td>{{Spec2('URL')}}</td>
<td>初期定義</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>
<div>
<p>{{Compat("api.URLSearchParams.sort")}}</p>
</div>
|