mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-25 13:48:53 +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 _b "strconv";func _g (_e byte )bool {return _e >='0'&&_e <='9'};func RepeatString (s string ,cnt int )string {if cnt <=0{return "";};_af :=make ([]byte ,len (s )*cnt );_c :=[]byte (s );for _de :=0;_de < cnt ;_de ++{copy (_af [_de :],_c );};return string (_af );};
|
|
|
|
// NaturalLess compares two strings in a human manner so rId2 sorts less than rId10
|
|
func NaturalLess (lhs ,rhs string )bool {_bf ,_bd :=0,0;for _bf < len (lhs )&&_bd < len (rhs ){_gd :=lhs [_bf ];_gg :=rhs [_bd ];_d :=_g (_gd );_gdb :=_g (_gg );switch {case _d &&!_gdb :return true ;case !_d &&_gdb :return false ;case !_d &&!_gdb :if _gd !=_gg {return _gd < _gg ;};_bf ++;_bd ++;default:_ggb :=_bf +1;_eb :=_bd +1;for _ggb < len (lhs )&&_g (lhs [_ggb ]){_ggb ++;};for _eb < len (rhs )&&_g (rhs [_eb ]){_eb ++;};_ge ,_ :=_b .ParseUint (lhs [_bf :_ggb ],10,64);_da ,_ :=_b .ParseUint (rhs [_bf :_eb ],10,64);if _ge !=_da {return _ge < _da ;};_bf =_ggb ;_bd =_eb ;};};return len (lhs )< len (rhs );}; |