Do not sort flaglist twice
authorDavor Ocelic <docelic@crystallabs.io>
Mon, 29 Apr 2019 00:16:14 +0200
changeset 107 3e31beb6c845
parent 106 94d941f13a5a
child 108 24340fdef276
Do not sort flaglist twice With this change, 'inspect'ing an element prints its attributes in a defined order: (requiredness, multivaluedness) Previously, the order was alphabetical and varying.
shelldap
--- a/shelldap	Mon Apr 29 00:10:31 2019 +0200
+++ b/shelldap	Mon Apr 29 00:16:14 2019 +0200
@@ -2327,6 +2327,9 @@
 	print "\nAttributes:\n";
 	foreach my $attr ( sort (@{$must_attr}, @{$may_attr}) ) {
 		my @flaglist;
+
+		push ( @flaglist, $must{$attr} ? 'required' : 'optional' );
+
 		if ( $self->{'schema'}->attribute( $attr )->{'single-value'} ) {
 			push ( @flaglist, 'single-value' );
 		}
@@ -2334,10 +2337,8 @@
 			push ( @flaglist, 'multivalue' );
 		}
 
-		push ( @flaglist, $must{$attr} ? 'required' : 'optional' );
-
 		my $flags = '';
-		$flags = (' (' . join( ', ', sort @flaglist ) . ')') if scalar @flaglist > 0;
+		$flags = (' (' . join( ', ', @flaglist ) . ')') if scalar @flaglist > 0;
 
 		printf( "    %s%s\n", $attr, $flags );
 	}