Use a LinkedHashMap to respect the order of the input data

Note: The int/real enumerated distributions do not specify that the
input must be sorted. This change supports the legacy behaviour enforced
by the unit test which is assuming input values are processed in
encounter order (which happens to be sorted).

Given int and double have a natural ordering it may be better to update
the distribution to sort input values. However this would contradict the
enumerated distribution which respects the input order of the list used
in the constructor.
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistribution.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistribution.java
index 010e82e..0e0cf1b 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistribution.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistribution.java
@@ -17,7 +17,7 @@
 package org.apache.commons.math4.legacy.distribution;
 
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -68,7 +68,7 @@
                NotFiniteNumberException,
                NotANumberException {
         innerDistribution = new EnumeratedDistribution<>(createDistribution(singletons,
-                                                                                   probabilities));
+                                                                            probabilities));
     }
 
     /**
@@ -78,7 +78,7 @@
      * @param data input dataset
      */
     public EnumeratedIntegerDistribution(final int[] data) {
-        final Map<Integer, Integer> dataMap = new HashMap<>();
+        final Map<Integer, Integer> dataMap = new LinkedHashMap<>();
         for (int value : data) {
             dataMap.merge(value, 1, Integer::sum);
         }
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistribution.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistribution.java
index 2d33dca..77385c8 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistribution.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistribution.java
@@ -17,7 +17,7 @@
 package org.apache.commons.math4.legacy.distribution;
 
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -80,7 +80,7 @@
      * @param data input dataset
      */
     public EnumeratedRealDistribution(final double[] data) {
-        final Map<Double, Integer> dataMap = new HashMap<>();
+        final Map<Double, Integer> dataMap = new LinkedHashMap<>();
         for (double value : data) {
             dataMap.merge(value, 1, Integer::sum);
         }