Skip to content

Instantly share code, notes, and snippets.

View primayudantra's full-sized avatar
👋
Hi, Prima here!

Prima Yudantra primayudantra

👋
Hi, Prima here!
View GitHub Profile
@primayudantra
primayudantra / gist:52cd9306349b1bd3543dc90eb976ff94
Created October 17, 2017 12:44 — forked from aodin/gist:9493190
Parsing JSON in a request body with Go
package main
import (
"encoding/json"
"io/ioutil"
"log"
"net/http"
)
type Message struct {
@primayudantra
primayudantra / sort-object-properties-by-value.md
Created July 31, 2017 09:14 — forked from umidjons/sort-object-properties-by-value.md
JavaScript: sort object properties by value (numeric or string)

Sort object properties by value (values are text)

I have following object:

var cities={10:'Tashkent', 14:'Karakalpakiya', 16:'Andijan'};

I want sort it by city names, so after sort it should be:

var cities={16:'Andijan', 14:'Karakalpakiya', 10:'Tashkent'};

But I can't sort object properties, instead can convert object into array, then sort items.