~michael.nelson/ubuntu-webcatalog/1267731-import-sca-apps-error

« back to all changes in this revision

Viewing changes to src/webcatalog/static/yui/3.10.3/build/arraysort/arraysort-debug.js

  • Committer: Tarmac
  • Author(s): Stephen Stewart
  • Date: 2013-06-26 09:19:32 UTC
  • mfrom: (184.1.4 ubuntu-global-nav)
  • Revision ID: tarmac-20130626091932-8urtuli368k8p7ds
[r=beuno,jonas-drange] add ubuntu global nav to apps.ubuntu.com

Show diffs side-by-side

added added

removed removed

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