How-to articles, tricks, and solutions about DATA-STRUCTURES

How do I sort a list of dictionaries by a value of the dictionary?

To sort a list of dictionaries by a value of the dictionary, you can use the sorted() function and specify the key parameter to be a lambda function that returns the value you want to sort by.

How to convert List to Map?

To convert a List to a Map in Java, you can use the stream() method and the collect() method along with a Collectors.toMap() call. Here's an example of how to do this:

How to implement a tree data-structure in Java?

A tree is a data structure that consists of nodes arranged in a hierarchy. Each node has a value and may have zero or more child nodes. The top node in a tree is called the root node.