Skip to content

Instantly share code, notes, and snippets.

@imevro
Last active December 15, 2015 13:58
Show Gist options
  • Select an option

  • Save imevro/5271006 to your computer and use it in GitHub Desktop.

Select an option

Save imevro/5271006 to your computer and use it in GitHub Desktop.
Алфавитная сортировка с разделением в объекты по первой букве
function sortByLetter( array ) {
var length = array.length,
groups = {},
item,
firstChar;
for ( var i = 0; i < length; i ++ ) {
item = array[ i ],
firstChar = item.charAt( 0 );
groups[ firstChar ] = groups[ firstChar ] || [];
groups[ firstChar ].push( item );
}
return groups;
}
@imevro

imevro commented Mar 29, 2013

Copy link
Copy Markdown
Author

@imevro

imevro commented Nov 29, 2013

Copy link
Copy Markdown
Author

Обновил для лучшей производительности.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment