Question: I want to get some informations through github API, i tried to use file\_get\_contents and it does not seem to work, so i moved to cURL, it does not give an error but it's not returning anything

PHP code :

```
if (!empty($_POST["username"])) {
        $ch=curl_init();
        curl_setopt($ch, CURLOPT_URL, "https://api.github.com/users/".$_POST["username"]);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        $output=curl_exec($ch);
        print_r($output);
        curl_close($ch);
    }

```

I checked the http code with CURLINFO\_HTTP\_CODE and its set to 0. is there any fix that i can get the json data when requesting.

Answer: 
I added a sort function into the mainLoop function, should sort numerically now.

```
function myFunction() {
  mainLoop()
}

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("sheet1");

function generateNumber(){
return Math.floor((Math.random()*200)+1)
}

function setValue(_val, _address){
   var cell =  sheet.getRange(_address)
   cell.setValue(_val)
}

function generate(){
  var array = []
  while(array.length<5){
    var rand = generateNumber()
    var isUnique = array.indexOf(rand) === -1
    if(isUnique){
      array.push(generateNumber())
    }

  }
  return array
}

function mainLoop(){
    var array = generate()
      array.sort(function(a, b) {
  return a - b;
});
    var addresses = ['I6','J6','K6','L6','M6']
    addresses.forEach(function (_address,_index){
        setValue(array[_index],_address)
    })
}

```
Something like this should do the trick.

```
function onOpen() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet();
  var entries = [{ name: "Roll Dice", functionName: "rollDice" }];
  sheet.addMenu("Script", entries);
}

function rollDice() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("sheet1 (New)");
  var numbers = [];
  while (numbers.length < 5) {
    var number = Math.floor(Math.random() * 200 + 1);
    if (numbers.indexOf(number) != -1) {
      numbers.push(number);
    }
  }
  numbers.sort((a, b) => a - b);
  ["I6", "J6", "K6", "L6", "M6"].forEach((addr, index) => {
    var cell = sheet.getRange(addr);
    cell.setValue(numbers[index]);
  });
}

```