~smagoun/whoopsie/whoopsie-lp1017637

« back to all changes in this revision

Viewing changes to backend/stats/static/js/yui/build/arraysort/arraysort-debug.js

  • Committer: Evan Dandrea
  • Date: 2012-05-09 05:53:45 UTC
  • Revision ID: evan.dandrea@canonical.com-20120509055345-z2j41tmcbf4as5uf
The backend now lives in lp:daisy and the website (errors.ubuntu.com) now lives in lp:errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.5.0 (build 5089)
3
 
Copyright 2012 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('arraysort', function(Y) {
8
 
 
9
 
/**
10
 
Provides a case-insenstive comparator which can be used for array sorting.
11
 
 
12
 
@module arraysort
13
 
*/
14
 
 
15
 
var LANG = Y.Lang,
16
 
    ISVALUE = LANG.isValue,
17
 
    ISSTRING = LANG.isString;
18
 
 
19
 
/**
20
 
Provides a case-insenstive comparator which can be used for array sorting.
21
 
 
22
 
@class ArraySort
23
 
*/
24
 
 
25
 
Y.ArraySort = {
26
 
 
27
 
    /**
28
 
    Comparator function for simple case-insensitive sorting of an array of
29
 
    strings.
30
 
 
31
 
    @method compare
32
 
    @param a {Object} First sort argument.
33
 
    @param b {Object} Second sort argument.
34
 
    @param desc {Boolean} `true` if sort direction is descending, `false` if
35
 
        sort direction is ascending.
36
 
    @return {Boolean} -1 when a < b. 0 when a == b. 1 when a > b.
37
 
    */
38
 
    compare: function(a, b, desc) {
39
 
        if(!ISVALUE(a)) {
40
 
            if(!ISVALUE(b)) {
41
 
                return 0;
42
 
            }
43
 
            else {
44
 
                return 1;
45
 
            }
46
 
        }
47
 
        else if(!ISVALUE(b)) {
48
 
            return -1;
49
 
        }
50
 
 
51
 
        if(ISSTRING(a)) {
52
 
            a = a.toLowerCase();
53
 
        }
54
 
        if(ISSTRING(b)) {
55
 
            b = b.toLowerCase();
56
 
        }
57
 
        if(a < b) {
58
 
            return (desc) ? 1 : -1;
59
 
        }
60
 
        else if (a > b) {
61
 
            return (desc) ? -1 : 1;
62
 
        }
63
 
        else {
64
 
            return 0;
65
 
        }
66
 
    }
67
 
 
68
 
};
69
 
 
70
 
 
71
 
}, '3.5.0' ,{requires:['yui-base']});