Skip to content

Commit

Permalink
use splice instead of filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ElinorW committed Oct 25, 2023
1 parent db03880 commit 79e7678
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/app/views/query-response/snippets/snippets-helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,16 @@ interface ISupportedLanguages {

export function renderSnippets(supportedLanguages: ISupportedLanguages) {
const sortedSupportedLanguages: ISupportedLanguages = {};
sortedSupportedLanguages.CSharp = supportedLanguages.CSharp;
Object.keys(supportedLanguages).filter((language) => language !== 'CSharp').sort().forEach(key => {
const sortedKeys = Object.keys(supportedLanguages).sort();

const cSharpIndex = sortedKeys.indexOf('CSharp');
if (cSharpIndex > -1) {
sortedKeys.splice(cSharpIndex, 1);
}

sortedKeys.unshift('CSharp');

sortedKeys.forEach(key => {
sortedSupportedLanguages[key] = supportedLanguages[key];
});

Expand Down

0 comments on commit 79e7678

Please sign in to comment.