mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-27 13:48:54 +08:00
15 lines
1.3 KiB
Go
15 lines
1.3 KiB
Go
//
|
|
// Copyright 2020 FoxyUtils ehf. All rights reserved.
|
|
//
|
|
// This is a commercial product and requires a license to operate.
|
|
// A trial license can be obtained at https://unidoc.io
|
|
//
|
|
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
|
|
//
|
|
// Use of this source code is governed by the UniDoc End User License Agreement
|
|
// terms that can be accessed at https://unidoc.io/eula/
|
|
|
|
package algo ;import _a "strconv";func _ab (_f byte )bool {return _f >='0'&&_f <='9'};func RepeatString (s string ,cnt int )string {if cnt <=0{return "";};_bd :=make ([]byte ,len (s )*cnt );_fc :=[]byte (s );for _fd :=0;_fd < cnt ;_fd ++{copy (_bd [_fd :],_fc );};return string (_bd );};
|
|
|
|
// NaturalLess compares two strings in a human manner so rId2 sorts less than rId10
|
|
func NaturalLess (lhs ,rhs string )bool {_de ,_c :=0,0;for _de < len (lhs )&&_c < len (rhs ){_cb :=lhs [_de ];_e :=rhs [_c ];_b :=_ab (_cb );_cg :=_ab (_e );switch {case _b &&!_cg :return true ;case !_b &&_cg :return false ;case !_b &&!_cg :if _cb !=_e {return _cb < _e ;};_de ++;_c ++;default:_cf :=_de +1;_db :=_c +1;for _cf < len (lhs )&&_ab (lhs [_cf ]){_cf ++;};for _db < len (rhs )&&_ab (rhs [_db ]){_db ++;};_g ,_ :=_a .ParseUint (lhs [_de :_cf ],10,64);_bc ,_ :=_a .ParseUint (rhs [_de :_db ],10,64);if _g !=_bc {return _g < _bc ;};_de =_cf ;_c =_db ;};};return len (lhs )< len (rhs );}; |