mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-11-02 19:47:54 +00:00 
			
		
		
		
	* remove .get() from cluster and vault route * replace .get() use in adapters * remove .get() from components part 1 * remove .get() from string-list * remaining components * controller .get() removal * remove .get() use in mixins * routes/cluster/access* .get() replacement * policy index route * routes/secrets/backend* * route/cluster* * serializers * is-active-route * remaining top-level addon gets * replication get() * revery change that broke things * woops, revert other store service change * revert some controller changes * revert get on URLSearchParams class * remove .sortBy ember method * small cleanup items * small cleanups from PR review
		
			
				
	
	
		
			24 lines
		
	
	
		
			681 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			681 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
/**
 | 
						|
 * Copyright (c) HashiCorp, Inc.
 | 
						|
 * SPDX-License-Identifier: BUSL-1.1
 | 
						|
 */
 | 
						|
 | 
						|
/* 
 | 
						|
this util sorts the original array
 | 
						|
pass in a copy of the array, i.e. myArray.slice(), if you do not want to modify the original array
 | 
						|
*/
 | 
						|
export default function sortObjects(array, key) {
 | 
						|
  if (Array.isArray(array) && array?.every((e) => e[key] && typeof e[key] === 'string')) {
 | 
						|
    return array.sort((a, b) => {
 | 
						|
      // ignore upper vs lowercase
 | 
						|
      const valueA = a[key].toUpperCase();
 | 
						|
      const valueB = b[key].toUpperCase();
 | 
						|
      if (valueA < valueB) return -1;
 | 
						|
      if (valueA > valueB) return 1;
 | 
						|
      return 0;
 | 
						|
    });
 | 
						|
  }
 | 
						|
  // if not sortable, return original array
 | 
						|
  return array;
 | 
						|
}
 |