function parseRedisServerList(key, serversString) {
  if (!serversString) return [];

  // convert array entries from string to object if needed
  if (Array.isArray(serversString)) {
    serversString.forEach(function(entry, index) {
      if (typeof entry === 'string') {
        const tmp = entry.trim().split(':');
        serversString[index] = {host: tmp[0].toLowerCase(), port: parseInt(tmp[1])};
      }
    });
    return serversString.sort((i1, i2) => ((i1.host.toLowerCase()) > i2.host.toLowerCase() || i1.port - i2.port));
  }

  if (typeof serversString !== 'string') {
    throw new Error(`Invalid type for key ${key}: must be either comma separated string with server or list of strings`);
  }

  try {
    const servers = [];
    if (serversString.startsWith('[')) {
      const obj = JSON.parse(serversString);
      obj.forEach(function(sentinel) {
        if (typeof sentinel === 'object') servers.push(sentinel);
        else {
          const tmp = sentinel.trim().split(':');
          servers.push({host: tmp[0].toLowerCase(), port: parseInt(tmp[1])});
        }
      });
    }
    else {
      // simple string, comma separated list of host:port
      const obj = serversString.split(',');
      obj.forEach(function(server) {
        if (server && server.trim()) {
          const tmp = server.trim().split(':');
          servers.push({host: tmp[0].toLowerCase(), port: parseInt(tmp[1])});
        }
      });
    }
    return servers.sort((i1, i2) => ((i1.host.toLowerCase()) > i2.host.toLowerCase() || i1.port - i2.port));
  }
  catch (e) {
    throw new Error(`Invalid type for key ${key}: Cannot parse redis server string - ${e.message}`);
  }
}
Parse a string with redis sentinel servers and ports to an objects as needed
 by ioredis for connections.

 Allowed formats are:
 <ul>
   <li>comma separated list of <code>hostname:port</code> values, port is optional</li>
   <li>JSON-String with list of <code>hostname:port</code> string entries</li>
   <li>JSON-String with list of sentinel objects <code>{"host":"localhost", "port": 26379}</code>
 </ul>

 The return value is a list with sentinel objects, e.g.: <code>{"host":"localhost", "port": 26379}</code>.
 The list is sorted (needed for easier comparison if this connection is already known)

 @param {string} key configuration key
 @param {string} serversString string or list object to check for valid sentinel or cluster connection data
 @return {object} ioredis server list as used for Sentinel or Cluster connections
 @private