Skip to content

Commit 16357a9

Browse files
committed
Sorting of networks within a protocol based on name
Signed-off-by: Oliver Hunt <oliver@hunt.bz>
1 parent ded2f95 commit 16357a9

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

‎src/components/views/directory/NetworkDropdown.js‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,21 @@ export default class NetworkDropdown extends React.Component {
150150
if (this.props.protocols) {
151151
for (const proto of Object.keys(this.props.protocols)) {
152152
if (!this.props.protocols[proto].instances) continue;
153-
for (const instance of this.props.protocols[proto].instances) {
153+
154+
const sortedInstances = this.props.protocols[proto].instances;
155+
sortedInstances.sort(function(x, y) {
156+
const a = x.desc
157+
const b = y.desc
158+
if (a < b) {
159+
return -1;
160+
} else if (a > b) {
161+
return 1;
162+
} else {
163+
return 0;
164+
}
165+
});
166+
167+
for (const instance of sortedInstances) {
154168
if (!instance.instance_id) continue;
155169
options.push(this._makeMenuOption(server, instance, false));
156170
}

0 commit comments

Comments
 (0)