diff --git a/app/Family.php b/app/Family.php
index a59bc27d86..ed2f14719b 100644
--- a/app/Family.php
+++ b/app/Family.php
@@ -310,6 +310,16 @@ public function getAllMarriagePlaces(): array
return [];
}
+ /**
+ * A closure which will compare families by marriage place.
+ *
+ * @return Closure(Family,Family):int
+ */
+ public static function marriagePlaceComparator(): Closure
+ {
+ return static fn (Family $x, Family $y): int => Place::compare($x->getMarriagePlace(), $y->getMarriagePlace());
+ }
+
/**
* Derived classes should redefine this function, otherwise the object will have no name
*
diff --git a/app/Individual.php b/app/Individual.php
index 661f49ce72..6fac2258cc 100644
--- a/app/Individual.php
+++ b/app/Individual.php
@@ -71,6 +71,36 @@ public static function deathDateComparator(): Closure
return static fn (Individual $x, Individual $y): int => Date::compare($x->getEstimatedDeathDate(), $y->getEstimatedDeathDate());
}
+ /**
+ * A closure which will compare individuals by birth place.
+ *
+ * @return Closure(Individual,Individual):int
+ */
+ public static function birthPlaceComparator(): Closure
+ {
+ return static fn (Individual $x, Individual $y): int => Place::compare($x->getBirthPlace(), $y->getBirthPlace());
+ }
+
+ /**
+ * A closure which will compare individuals by death place.
+ *
+ * @return Closure(Individual,Individual):int
+ */
+ public static function deathPlaceComparator(): Closure
+ {
+ return static fn (Individual $x, Individual $y): int => Place::compare($x->getDeathPlace(), $y->getDeathPlace());
+ }
+
+ /**
+ * A closure which will compare individuals by burial place.
+ *
+ * @return Closure(Individual,Individual):int
+ */
+ public static function burialPlaceComparator(): Closure
+ {
+ return static fn (Individual $x, Individual $y): int => Place::compare($x->getBurialPlace(), $y->getBurialPlace());
+ }
+
/**
* Can the name of this record be shown?
*
@@ -414,6 +444,22 @@ public function getDeathPlace(): Place
return new Place('', $this->tree);
}
+ /**
+ * Get the place of burial
+ *
+ * @return Place
+ */
+ public function getBurialPlace(): Place
+ {
+ $places = $this->getAllEventPlaces(['BURI']);
+
+ foreach ($places as $place) {
+ return $place;
+ }
+
+ return new Place('', $this->tree);
+ }
+
/**
* Get the range of years in which a individual lived. e.g. “1870–”, “1870–1920”, “–1920”.
* Provide the place and full date using a tooltip.
diff --git a/app/Place.php b/app/Place.php
index 01d11141c9..406b28284d 100644
--- a/app/Place.php
+++ b/app/Place.php
@@ -292,4 +292,28 @@ public function shortName(bool $link = false): string
return '' . e($short_name) . '';
}
+
+ /**
+ * Compare two places, so they can be sorted.
+ * return -1 if $a<$b
+ * return +1 if $b>$a
+ * return 0 if places are the same
+ *
+ * @param Place $a
+ * @param Place $b
+ * @return int
+ */
+ public static function compare(Place $a, Place $b): int
+ {
+ return strcasecmp($a->reversedFullName(), $b->reversedFullName());
+ }
+
+ private function reversedFullName(): string
+ {
+ if ($this->parts->isEmpty()) {
+ return '';
+ }
+ return $this->parts->reverse()->implode(I18N::$list_separator);
+ }
+
}
diff --git a/app/Report/ReportParserGenerate.php b/app/Report/ReportParserGenerate.php
index 53633a8eff..21d33b7116 100644
--- a/app/Report/ReportParserGenerate.php
+++ b/app/Report/ReportParserGenerate.php
@@ -1699,12 +1699,24 @@ protected function listStartHandler(array $attrs): void
case 'BIRT:DATE':
uasort($this->list, Individual::birthDateComparator());
break;
+ case 'BIRT:PLAC':
+ uasort($this->list, Individual::birthPlaceComparator());
+ break;
case 'DEAT:DATE':
uasort($this->list, Individual::deathDateComparator());
break;
+ case 'DEAT:PLAC':
+ uasort($this->list, Individual::deathPlaceComparator());
+ break;
+ case 'BURI:PLAC':
+ uasort($this->list, Individual::burialPlaceComparator());
+ break;
case 'MARR:DATE':
uasort($this->list, Family::marriageDateComparator());
break;
+ case 'MARR:PLAC':
+ uasort($this->list, Family::marriagePlaceComparator());
+ break;
default:
// unsorted or already sorted by SQL
break;
diff --git a/resources/xml/reports/birth_report.xml b/resources/xml/reports/birth_report.xml
index 3dc06d46bd..0eeb2246ac 100644
--- a/resources/xml/reports/birth_report.xml
+++ b/resources/xml/reports/birth_report.xml
@@ -6,7 +6,7 @@
-
+