[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Mon, 5 Feb 2024 01:52:40 -0500 (EST) |
branch: master
commit b1201606745cf4186d851971bf26334a771a1a31
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Feb 5 07:52:26 2024 +0100
* tp/Texinfo/Indices.pm (sort_indices_by_letter): setup a sort string
for letters sorting. Do not sort explicitely symbols before letters.
Remove _collator_sort_string.
---
ChangeLog | 6 ++++++
tp/Texinfo/Indices.pm | 32 +++++++++++++-------------------
2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 364e2f63ed..38d8e9a54c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-02-05 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Indices.pm (sort_indices_by_letter): setup a sort string
+ for letters sorting. Do not sort explicitely symbols before letters.
+ Remove _collator_sort_string.
+
2024-02-05 Patrice Dumas <pertusus@free.fr>
* Texinfo/Indices.pm (_index_entry_element_sort_string_key)
diff --git a/tp/Texinfo/Indices.pm b/tp/Texinfo/Indices.pm
index ccbc77cdf6..a3d04b6574 100644
--- a/tp/Texinfo/Indices.pm
+++ b/tp/Texinfo/Indices.pm
@@ -138,17 +138,6 @@ sub _sort_index_entries($$)
return $res;
}
-sub _collator_sort_string($$$)
-{
- my $a = shift;
- my $b = shift;
- my $collator = shift;
- return (($a =~ /^[[:alpha:]]/ and $b =~ /^[[:alpha:]]/)
- or ($a !~ /^[[:alpha:]]/ and $b !~ /^[[:alpha:]]/))
- ? ($collator->cmp ($a, $b))
- : (($a =~ /^[[:alpha:]]/ && 1) || -1);
-}
-
sub setup_index_entry_keys_formatting($)
{
my $customization_information = shift;
@@ -634,15 +623,20 @@ sub sort_indices_by_letter($$$$;$)
push @{$index_letter_hash->{$letter}}, $sortable_entry;
}
- # need to use directly the collator here as there is no
- # separate sort keys.
- my @sorted_letters = sort {_collator_sort_string($a, $b, $collator)}
- (keys %$index_letter_hash);
- foreach my $letter (@sorted_letters) {
- my @sorted_letter_entries;
- @sorted_letter_entries
+
+ my @letter_keys;
+ foreach my $letter (keys %$index_letter_hash) {
+ my $sort_key = $collator->getSortKey($letter);
+ push @letter_keys, [$sort_key, $letter, $index_letter_hash->{$letter}];
+ }
+
+ my @sorted_letters = sort{$a->[0] cmp $b->[0]} @letter_keys;
+
+ foreach my $letter_and_entries (@sorted_letters) {
+ my $letter = $letter_and_entries->[1];
+ my @sorted_letter_entries
= map {$_->{'entry'}} sort {_sort_index_entries($a, $b)}
- @{$index_letter_hash->{$letter}};
+ @{$letter_and_entries->[2]};
push @{$sorted_index_entries->{$index_name}},
{ 'letter' => $letter, 'entries' => \@sorted_letter_entries };
}