From 16357a9bc7ed4a635911811642fe04b368194108 Mon Sep 17 00:00:00 2001 From: Oliver Hunt Date: Sat, 27 May 2017 17:31:28 +0100 Subject: [PATCH] Sorting of networks within a protocol based on name Signed-off-by: Oliver Hunt --- .../views/directory/NetworkDropdown.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/views/directory/NetworkDropdown.js b/src/components/views/directory/NetworkDropdown.js index c891ee5b..9c19cdbc 100644 --- a/src/components/views/directory/NetworkDropdown.js +++ b/src/components/views/directory/NetworkDropdown.js @@ -150,7 +150,21 @@ export default class NetworkDropdown extends React.Component { if (this.props.protocols) { for (const proto of Object.keys(this.props.protocols)) { if (!this.props.protocols[proto].instances) continue; - for (const instance of this.props.protocols[proto].instances) { + + const sortedInstances = this.props.protocols[proto].instances; + sortedInstances.sort(function(x, y) { + const a = x.desc + const b = y.desc + if (a < b) { + return -1; + } else if (a > b) { + return 1; + } else { + return 0; + } + }); + + for (const instance of sortedInstances) { if (!instance.instance_id) continue; options.push(this._makeMenuOption(server, instance, false)); }