File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2557,6 +2557,39 @@ function strOrFunc(arg, args) {
25572557 return arg ;
25582558}
25592559
2560+ function sortArrayByKey ( arrayToSort , sortKey , reverse ) {
2561+
2562+ if ( ! arrayToSort ) {
2563+ return ;
2564+ }
2565+ // Move smaller items towards the front
2566+ // or back of the array depending on if
2567+ // we want to sort the array in reverse
2568+ // order or not.
2569+ var moveSmaller = reverse ? 1 : - 1 ;
2570+
2571+ // Move larger items towards the front
2572+ // or back of the array depending on if
2573+ // we want to sort the array in reverse
2574+ // order or not.
2575+ var moveLarger = reverse ? - 1 : 1 ;
2576+
2577+ /**
2578+ * @param {* } a
2579+ * @param {* } b
2580+ * @return {Number }
2581+ */
2582+ arrayToSort . sort ( function ( a , b ) {
2583+ if ( a [ sortKey ] < b [ sortKey ] ) {
2584+ return moveSmaller ;
2585+ }
2586+ if ( a [ sortKey ] > b [ sortKey ] ) {
2587+ return moveLarger ;
2588+ }
2589+ return 0 ;
2590+ } ) ;
2591+ }
2592+
25602593$ . validator . addMethod ( "netmask" , function ( value , element ) {
25612594 if ( this . optional ( element ) && value . length == 0 )
25622595 return true ;
Original file line number Diff line number Diff line change 809809 $step . find ( '.main-desc, p.no-affinity-groups' ) . remove ( ) ;
810810
811811 if ( args . data . affinityGroups && args . data . affinityGroups . length ) {
812+
813+ sortArrayByKey ( args . data . affinityGroups , 'name' ) ;
814+
812815 $step . prepend (
813816 $ ( '<div>' ) . addClass ( 'main-desc' ) . append (
814817 $ ( '<p>' ) . html ( _l ( 'message.select.affinity.groups' ) )
855858 $step . find ( '.main-desc, p.no-sshkey-pairs' ) . remove ( ) ;
856859
857860 if ( args . data . sshkeyPairs && args . data . sshkeyPairs . length ) {
861+
862+ sortArrayByKey ( args . data . sshkeyPairs , 'name' ) ;
863+
858864 $step . prepend (
859865 $ ( '<div>' ) . addClass ( 'main-desc' ) . append (
860866 $ ( '<p>' ) . html ( _l ( 'message.please.select.ssh.key.pair.use.with.this.vm' ) )
10241030
10251031 // Populate VPC drop-down
10261032 $vpcSelect . html ( '' ) ;
1033+
1034+ sortArrayByKey ( vpcs , 'name' ) ;
1035+
10271036 $ ( vpcs ) . map ( function ( index , vpc ) {
10281037 var $option = $ ( '<option>' ) ;
10291038 var id = vpc . id ;
You can’t perform that action at this time.
0 commit comments