Fix sorting of Ion identities
/*
- * Copyright 2006-2020 The MZmine Development Team
+ * Copyright 2006-2021 The MZmine Development Team
*
* This file is part of MZmine.
*
* License, or (at your option) any later version.
*
* MZmine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
- * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with MZmine; if not,
- * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
*/
package io.github.mzmine.datamodel.identities.iontype;
@@ -434,15 +435,16 @@ public class IonNetworkLogic {
*/
public static List<IonIdentity> sortIonIdentities(FeatureListRow row, boolean useGroup) {
List<IonIdentity> ident = row.getIonIdentities();
- if (ident == null) {
+ if (ident == null || ident.isEmpty()) {
return null;
}
RowGroup group = useGroup ? row.getGroup() : null;
// best is first
- ident.stream().sorted(((Comparator<IonIdentity>) (a, b) -> compareRows(a, b, group)).reversed())
- .toList();
+ final List<IonIdentity> sorted = ident.stream()
+ .sorted(((Comparator<IonIdentity>) (a, b) -> compareRows(a, b, group)).reversed()).toList();
+ row.setIonIdentities(sorted);
return ident;
}
