mirror of
https://github.com/processing/processing4.git
synced 2026-02-04 06:09:17 +01:00
prevent Table.sort() from throwing NPE with empty cells
This commit is contained in:
@@ -4350,7 +4350,15 @@ public class Table {
|
||||
double diffd = getDouble(a, column) - getDouble(b, column);
|
||||
return diffd == 0 ? 0 : (diffd < 0 ? -1 : 1);
|
||||
case STRING:
|
||||
return getString(a, column).compareToIgnoreCase(getString(b, column));
|
||||
String string1 = getString(a, column);
|
||||
if (string1 == null) {
|
||||
string1 = ""; // avoid NPE when cells are left empty
|
||||
}
|
||||
String string2 = getString(b, column);
|
||||
if (string2 == null) {
|
||||
string2 = "";
|
||||
}
|
||||
return string1.compareToIgnoreCase(string2);
|
||||
case CATEGORY:
|
||||
return getInt(a, column) - getInt(b, column);
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user