What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-02-06 08:50:05
js sort array of objects
const books = [ {id: 1, name: 'The Lord of the Rings'}, {id: 2, name: 'A Tale of Two Cities'}, {id: 3, name: 'Don Quixote'}, {id: 4, name: 'The Hobbit'} ] books.sort((a,b) => (a.name > b.name) ? 1 : ((b.name > a.name) ? -1 : 0)); Add solution -
Other 2022-02-03 11:36:54
maximum number from Array
---without sort method--- public static int maxValue( int[] n ) { int max = Integer.MIN_VALUE; for(int each: n) if(each > max) max = each; return max; ---with sort method--- public static int maxValue( int[] n ) { Arrays.sort( n ); return... Add solution -
Java 2022-02-02 12:10:52
java overloading
Overloading mean same method name and different parameter, it can happen in same class. it's a feature that allows us to have more than one method with same name. Example: sort method of Arrays class Arrays.sort(int[] arr) Arrays.sort(String[] arr) ...... Add solution -
Python 2022-02-02 05:47:06
sort array python
my_list = [9, 3, 1, 5, 88, 22, 99] # sort in decreasing order my_list = sorted(my_list, reverse=True) print(my_list) # sort in increasing order my_list = sorted(my_list, reverse=False) print(my_list) # another way to sort using built-in methods my_li... Add solution -
Python 2022-02-01 22:07:03
list sort python
my_list = [9, 3, 1, 5, 88, 22, 99] # sort in decreasing order my_list = sorted(my_list, reverse=True) print(my_list) # sort in increasing order my_list = sorted(my_list, reverse=False) print(my_list) # another way to sort using built-in methods my_li... Add solution -
Javascript 2022-02-01 12:06:57
8.3.1. Common Array Methods // sort Examples (.sort)
//The general syntax for this method is: arrayName.sort() /*This method arranges the elements of an array into increasing order. For strings, this means alphabetical order. HOWEVER, the results are not always what we expect.*/ let letters = ['f', 'c',... Add solution -
Python 2022-02-01 04:20:03
collecting candies codevita solution in python
T = int(input()) arr1 = [] for i in range(0, T): N = int(input()) arr = list(map(int,input().split())) arr.sort() count = arr[0] for i in range(1, len(arr)): count = count + arr[i] arr1.append(count) print(sum(arr1)) Add solution
Best helpers
Ranking is empty