By adding after: ``` aVal = valueOf(a, keyPaths[i].path); bVal = valueOf(b, keyPaths[i].path); ``` this: ``` if (typeof valueOf(a, keyPaths[i].path) == 'string' && typeof valueOf(b, keyPaths[i].path) == 'string'){ aVal = aVal.toLowerCase(); bVal = bVal.toLowerCase(); } ``` fixes the issue :)