# sort strings

{% tabs %}
{% tab title="code" %}
```javascript
// sort strings
strings.sort((a, b) => a.localeCompare(b))
```
{% endtab %}

{% tab title="🗣 討論" %}
* [How to sort strings in JavaScript](https://stackoverflow.com/a/51169/5409815)
{% endtab %}

{% tab title="📘 手冊" %}
* String ⟩ [.localeCompare()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare)
{% endtab %}
{% endtabs %}
