Skip to content

Instantly share code, notes, and snippets.

View adexh's full-sized avatar

Adesh Tamrakar adexh

View GitHub Profile
@adexh
adexh / sortObjectByKeys.js
Created July 22, 2024 17:38
Approach to sort an object on the basis of keys
const obj = [{ "name": "John", "age": 30, "city": "New York", "country": "USA", "Hobbies": ["reading", "swimming", "hiking", "swimming"], "occupation": "programmer", "favorite_foods": { "Breakfast": "pancakes", "Lunch": "", "dinner": "pasta", "Snack": "" }, "gear": { "type": "", "material": "", "color": null }, "affiliations": ["", "", ""], "friends": [{ "name": "Jane", "age": 28, "city": "New York", "country": "USA", "occupation": null }, { "name": "Tom", "age": 32, "city": "London", "country ": "UK", "occupation": "teacher" }, { "name": "Jane", "age": 28, "city": "NewYork", "country": "USA", "occupation": null }] }];
class ObjectSorted {
constructor() {
this.keySet = [];
this.objectStore = {}
}
set(key, value) {
if (value) {
@adexh
adexh / .java
Created May 27, 2024 17:53
geeksforgeeks.org/problems/chocolates-pickup/1
//{ Driver Code Starts
//Initial Template for Java
import java.util.*;
import java.lang.*;
import java.io.*;
class GFG{
public static void main(String args[]) throws IOException{
Scanner sc=new Scanner(System.in);