Question: How do I turn a repeat number such as:

```
999117777774422111

```

Create output: //

```
 999, 11, 777777, 44, 22, 111

```

I basically want to separate the value when the digits change from the [i]th place.

Answer: 
That is not really sorting but more like comparing.

**Here is a solution**:

```js
var str = "999117777774422111";
var out = str[0];

for (var i = 1; i < str.length; i++) {
  if (str[i] == str[i-1]) {
    out += str[i];
  } else {
    out += ", " + str[i];
  }
}

console.log(out);
```

---

**Or sending the output as array:**

```js
var str = "999117777774422111";
var out = [str[0]];

var j = 0;

for (var i = 1; i < str.length; i++) {
  if (str[i] != str[i-1]) {
    j++;
    out[j] = "";
  }

  out[j] += str[i];
}

console.log(out);
```
try this:

```js
let num='999117777774422111';
let result=num.match(/(\d)\1*/g);
console.log(result);
```