Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

18
LINES

< > BotCompany Repo | #1013287 // compareIgnoreCase_lower - uses toLower method

JavaX fragment (include)

1  
static int compareIgnoreCase_lower(S s1, S s2) {
2  
  if (s1 == null) ret s2 == null ? 0 : -1;
3  
  if (s2 == null) ret 1;
4  
  
5  
  int n1 = s1.length();
6  
  int n2 = s2.length();
7  
  int min = Math.min(n1, n2);
8  
  for (int i = 0; i < min; i++) {
9  
    char c1 = s1.charAt(i);
10  
    char c2 = s2.charAt(i);
11  
    if (c1 != c2) {
12  
      c1 = Character.toLowerCase(c1);
13  
      c2 = Character.toLowerCase(c2);
14  
      if (c1 != c2) ret c1-c2;
15  
    }
16  
  }
17  
  ret n1-n2;
18  
}

Author comment

Began life as a copy of #1004962

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1013287
Snippet name: compareIgnoreCase_lower - uses toLower method
Eternal ID of this version: #1013287/1
Text MD5: 7c33d41b0a26d28f58ef0fd58a0e75b8
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-31 07:26:36
Source code size: 456 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 483 / 513
Referenced in: [show references]