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 _e "strconv";
|
|
|
|
// NaturalLess compares two strings in a human manner so rId2 sorts less than rId10
|
|
func NaturalLess (lhs ,rhs string )bool {_ff ,_ab :=0,0;for _ff < len (lhs )&&_ab < len (rhs ){_fc :=lhs [_ff ];_ee :=rhs [_ab ];_gg :=_g (_fc );_d :=_g (_ee );switch {case _gg &&!_d :return true ;case !_gg &&_d :return false ;case !_gg &&!_d :if _fc !=_ee {return _fc < _ee ;};_ff ++;_ab ++;default:_c :=_ff +1;_eb :=_ab +1;for _c < len (lhs )&&_g (lhs [_c ]){_c ++;};for _eb < len (rhs )&&_g (rhs [_eb ]){_eb ++;};_fff ,_ :=_e .ParseUint (lhs [_ff :_c ],10,64);_dd ,_ :=_e .ParseUint (rhs [_ff :_eb ],10,64);if _fff !=_dd {return _fff < _dd ;};_ff =_c ;_ab =_eb ;};};return len (lhs )< len (rhs );};func RepeatString (s string ,cnt int )string {if cnt <=0{return "";};_ggc :=make ([]byte ,len (s )*cnt );_b :=[]byte (s );for _ea :=0;_ea < cnt ;_ea ++{copy (_ggc [_ea :],_b );};return string (_ggc );};func _g (_a byte )bool {return _a >='0'&&_a <='9'}; |