Last active
August 29, 2015 14:04
-
-
Save relational/8fd4e5bfaf353fdec45b to your computer and use it in GitHub Desktop.
Sort fyrir íslenska stafi, einföld lausn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var app = angular.module('store', []); | |
app.controller('ListController', function () { | |
this.list = ['Ísland', 'Þórshöfn', 'Hljómsveit', 'Æðibiti']; | |
this.is2ascii = (function () { | |
var is_ascii = { | |
"A": "AA", | |
"Á": "AB", | |
"B": "AC", | |
"D": "AD", | |
"Ð": "AE", | |
"E": "AF", | |
"É": "AG", | |
"F": "AH", | |
"G": "AI", | |
"H": "AJ", | |
"I": "AK", | |
"Í": "AL", | |
"J": "AM", | |
"K": "AN", | |
"L": "AO", | |
"M": "AP", | |
"N": "AQ", | |
"O": "AR", | |
"Ó": "AS", | |
"P": "AT", | |
"R": "AU", | |
"S": "AV", | |
"T": "AX", | |
"U": "AY", | |
"Ú": "AZ", | |
"V": "BA", | |
"X": "BB", | |
"Y": "BC", | |
"Ý": "BD", | |
"Z": "BE", | |
"Þ": "BF", | |
"Æ": "BG", | |
"Ö": "BH", | |
"a": "aa", | |
"á": "ab", | |
"b": "ac", | |
"d": "ad", | |
"ð": "ae", | |
"e": "af", | |
"é": "ag", | |
"f": "ah", | |
"g": "ai", | |
"h": "aj", | |
"i": "ak", | |
"í": "al", | |
"j": "am", | |
"k": "an", | |
"l": "ao", | |
"m": "ap", | |
"n": "aq", | |
"o": "ar", | |
"ó": "as", | |
"p": "at", | |
"r": "au", | |
"s": "av", | |
"t": "ax", | |
"u": "ay", | |
"ú": "az", | |
"v": "ba", | |
"x": "bb", | |
"y": "bc", | |
"z": "bd", | |
"ý": "be", | |
"þ": "bf", | |
"æ": "bg", | |
"ö": "bh" | |
}; | |
return (function (str) { | |
return str.split("").map(function (s) { | |
if (s in is_ascii) return is_ascii[s]; | |
else return s; | |
}).join(""); | |
}); | |
})(); | |
}); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app="store"> | |
<head> | |
<meta charset="UTF-8"> | |
</head> | |
<body ng-controller="ListController as lc"> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.min.js"></script> | |
<script src="app.js"></script> | |
<p ng-repeat="item in lc.list | orderBy: lc.is2ascii "> {{ item }}</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment