>
% if ( $i == 0 ) {
% my $options = $tiers_by_key->[0]->{''};
-% foreach ( sort keys %$options ) {
+% #foreach ( sort keys %$options ) {
+% foreach ( sort { lc($options->{$a}) cmp lc($options->{$b}) }
+% keys %$options
+% )
+% {
<OPTION VALUE="<%$_ |h%>" <% $curr_values->[$i] eq $_ ? 'SELECTED' : ''%>>
<% $options->{$_} |h%></OPTION>
% }
</SELECT>
<% $tier->{after} %>
% } #foreach $tier
+
<SCRIPT type="text/javascript">
-% my $json = JSON->new->canonical; #sort
var <% $pre %>tiers = <% $json->encode($tiers_by_key) %>;
var <% $pre %>curr_values = <% $json->encode($curr_values) %>;
function <% $pre %>select_change(select_this, i) {
my $pre = $opt{prefix} || '';
my $tiers = $opt{tiers} or die "no tiers defined";
+#my $json = JSON->new()->canonical(); #sort
+# something super weird and broken going on with JSON's auto-loading, just
+# using JSON alone errors out with
+# Can't locate object method "new" via package "null" (perhaps you forgot to
+# load "null"?)
+# yes, "null", not "JSON". so instead, using JSON::XS explicity...
+use JSON::XS;
+my $json = JSON::XS->new();
+$json->canonical;
+
my $i;
for( $i = 0; $i < @$tiers; $i++ ) {
my $tier = $tiers->[$i];