… | |
… | |
1941 | $r |
1941 | $r |
1942 | } |
1942 | } |
1943 | |
1943 | |
1944 | my %SORT_ORDER = ( |
1944 | my %SORT_ORDER = ( |
1945 | type => sub { |
1945 | type => sub { |
|
|
1946 | use sort 'stable'; |
1946 | sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ |
1947 | sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ |
1947 | }, |
1948 | }, |
1948 | mtime => sub { |
1949 | mtime => sub { |
|
|
1950 | use sort 'stable'; |
1949 | my $NOW = time; |
1951 | my $NOW = time; |
1950 | sort { |
1952 | sort { |
1951 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1953 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1952 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
1954 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
1953 | |
1955 | |
1954 | ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) |
1956 | ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) |
1955 | or $btime <=> $atime |
1957 | or $btime <=> $atime |
1956 | or $a->{type} <=> $b->{type} |
1958 | or $a->{type} <=> $b->{type} |
1957 | } @_ |
1959 | } @_ |
1958 | }, |
1960 | }, |
1959 | weight => sub { sort { |
1961 | weight => sub { |
|
|
1962 | use sort 'stable'; |
|
|
1963 | sort { |
1960 | $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) |
1964 | $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) |
1961 | or $a->{type} <=> $b->{type} |
1965 | or $a->{type} <=> $b->{type} |
1962 | } @_ }, |
1966 | } @_ |
|
|
1967 | }, |
1963 | ); |
1968 | ); |
1964 | |
1969 | |
1965 | sub inventory_widget { |
1970 | sub inventory_widget { |
1966 | my $hb = new DC::UI::HBox homogeneous => 1; |
1971 | my $hb = new DC::UI::HBox homogeneous => 1; |
1967 | |
1972 | |