textmacro sort

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Allows sorting of arbitrary type arrays (+ bonus printing them). The "algorithm" used is called "Selection Sort" I think.
All functions/textmacros work in the range [a, b)

The comparison function which is required by the sort_handles_<asc|desc> functions and is user defined and is of the form
[ljass]function <comparison_function_name> takes <type v1, type v2> returns boolean[/ljass]

Example:
[ljass]function comp_unit_hp takes unit u1, unit u2 returns boolean[/ljass]
[ljass] return GetWidgetLife(u1) > GetWidgetLife(u2)[/ljass]
[ljass]endfunction[/ljass]

The suffix _asc means sort in ascending order (0, 1, 2, 3, 4)
The suffix _desc means sort in descending order (4, 3, 2, 1, 0)

"Interface":
For arrays of type integer and real:
[ljass]//! runtextmacro sort_numbers_asc takes string array_name, string a, string b[/ljass]
[ljass]//! runtextmacro sort_numbers_desc takes string array_name, string a, string b[/ljass]

[ljass]//! runtextmacro sort_strings_asc takes string array_name, string a, string b[/ljass]
[ljass]//! runtextmacro sort_strings_desc takes string array_name, string a, string b[/ljass]

[ljass]//! runtextmacro sort_handles_asc takes string array_name, string a, string b, string comparison_function_name, string type_name[/ljass]
[ljass]//! runtextmacro sort_handles_desc takes string array_name, string a, string b, string comparison_function_name, string type_name[/ljass]

The say_a function/textmacro stands for "say_array" (say is an easy to type name for printing used in Perl and maybe some other programming languages)
The last parameter is the conversion function's name that converts the type of the array to string. (example: I2S, R2S, S2S (Yes string 2 string =)), GetUnitName, etc.)
[ljass]//! runtextmacro say_a takes takes string array_name, string a, string b, string to_string_function_name[/ljass]

Group to array conversion that does not alter the passed group
[ljass]//! runtextmacro group2array takes string group_name, string array_name[/ljass]

Note:
Sorting big arrays (size > 50 [huge eh? =)] is not recommended especially for sorting strings becuase it is very likely to hit the oplimit count.
Why will sorting hit the oplimit? Well first of all the sorting functions/textmacros inline in the functions/methods that use them, second
the algorithm used is probably one of the worst because it requires a lot of swapping/checking, so sorting will eat your oplimit count and that's a fact.
Why not use a better sorting then? Well simply because a proper fast sorting algorithm is hard to do right and in my case I really don't know how.
Some folks proposed in the comments below to use quicksort, which is a better sorting method but it seams it's implementation (the ones I finds at least)
require functions calls and this is not practical in the case of [v]Jass[2] because arrays cannot be passed as arguments hence the reason to inline the sorting
routine. If someone knows a faster algorithm that inlines (does not require functions calls/array passing), then he might be able to write a much better sorting
routines. Although you might get away with integer/real type arrays of 50 <= size <= 150.


JASS:
library TcA2II2A
    globals
        private hashtable     a2i_map     = InitHashtable()
        private string        a2i_string  = &quot;&quot;
        private integer       a2i_integer = 0

        private string  array i2a_map 
        private integer       i2a_integer = 0
        private string        i2a_string  = &quot;&quot;
    endglobals

    private function SH2 takes string s returns integer
        if s == StringCase(s, true) then
            return StringHash(s)
        else
            return StringHash(s) + 1
        endif
    endfunction

    module a2i_loader
        private static method onInit takes nothing returns nothing

            call SaveInteger(a2i_map, 0x100, SH2(&quot; &quot;), 32)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;!&quot;), 33)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;\&quot;&quot;), 34)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;#&quot;), 35)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;$&quot;), 36)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;%&quot;), 37)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;&amp;&quot;), 38)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;&#039;&quot;), 39)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;(&quot;), 40)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;)&quot;), 41)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;*&quot;), 42)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;+&quot;), 43)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;,&quot;), 44)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;-&quot;), 45)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;.&quot;), 46)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;/&quot;), 47)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;0&quot;), 48)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;1&quot;), 49)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;2&quot;), 50)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;3&quot;), 51)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;4&quot;), 52)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;5&quot;), 53)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;6&quot;), 54)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;7&quot;), 55)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;8&quot;), 56)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;9&quot;), 57)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;:&quot;), 58)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;;&quot;), 59)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;&lt;&quot;), 60)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;=&quot;), 61)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;&gt;&quot;), 62)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;?&quot;), 63)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;@&quot;), 64)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;A&quot;), 65)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;B&quot;), 66)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;C&quot;), 67)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;D&quot;), 68)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;E&quot;), 69)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;F&quot;), 70)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;G&quot;), 71)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;H&quot;), 72)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;I&quot;), 73)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;J&quot;), 74)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;K&quot;), 75)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;L&quot;), 76)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;M&quot;), 77)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;N&quot;), 78)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;O&quot;), 79)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;P&quot;), 80)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;Q&quot;), 81)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;R&quot;), 82)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;S&quot;), 83)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;T&quot;), 84)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;U&quot;), 85)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;V&quot;), 86)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;W&quot;), 87)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;X&quot;), 88)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;Y&quot;), 89)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;Z&quot;), 90)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;[&quot;), 91)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;\\&quot;), 92)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;]&quot;), 93)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;^&quot;), 94)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;_&quot;), 95)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;`&quot;), 96)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;a&quot;), 97)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;b&quot;), 98)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;c&quot;), 99)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;d&quot;), 100)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;e&quot;), 101)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;f&quot;), 102)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;g&quot;), 103)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;h&quot;), 104)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;i&quot;), 105)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;j&quot;), 106)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;k&quot;), 107)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;l&quot;), 108)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;m&quot;), 109)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;n&quot;), 110)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;o&quot;), 111)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;p&quot;), 112)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;q&quot;), 113)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;r&quot;), 114)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;s&quot;), 115)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;t&quot;), 116)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;u&quot;), 117)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;v&quot;), 118)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;w&quot;), 119)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;x&quot;), 120)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;y&quot;), 121)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;z&quot;), 122)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;{&quot;), 123)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;|&quot;), 124)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;}&quot;), 125)
            call SaveInteger(a2i_map, 0x100, SH2(&quot;~&quot;), 126)
        
        endmethod
    endmodule

    struct a2i_loader_dummy
        implement a2i_loader
    endstruct

    function sub_A2I takes nothing returns nothing
        if 1 == StringLength(a2i_string) then
            set a2i_integer = LoadInteger(a2i_map, 0x100, SH2(a2i_string))
        else
            set a2i_integer = LoadInteger(a2i_map, 0x100, SH2(SubString(a2i_string, 0, 1))) * 0x1000000 + /*
                           */ LoadInteger(a2i_map, 0x100, SH2(SubString(a2i_string, 1, 2))) * 0x10000   + /*
                           */ LoadInteger(a2i_map, 0x100, SH2(SubString(a2i_string, 2, 3))) * 0x100     + /*
                           */ LoadInteger(a2i_map, 0x100, SH2(SubString(a2i_string, 3, 4)))  
        endif
    endfunction

    function A2I takes string a returns integer
        set a2i_string =  a
        call ExecuteFunc(&quot;sub_A2I&quot;)
        return a2i_integer
    endfunction


    module i2a_loader
        private static method onInit takes nothing returns nothing

            set i2a_map[32]  = &quot; &quot;
            set i2a_map[33]  = &quot;!&quot;
            set i2a_map[34]  = &quot;\&quot;&quot;
            set i2a_map[35]  = &quot;#&quot;
            set i2a_map[36]  = &quot;$&quot;
            set i2a_map[37]  = &quot;%&quot;
            set i2a_map[38]  = &quot;&amp;&quot;
            set i2a_map[39]  = &quot;&#039;&quot;
            set i2a_map[40]  = &quot;(&quot;
            set i2a_map[41]  = &quot;)&quot;
            set i2a_map[42]  = &quot;*&quot;
            set i2a_map[43]  = &quot;+&quot;
            set i2a_map[44]  = &quot;,&quot;
            set i2a_map[45]  = &quot;-&quot;
            set i2a_map[46]  = &quot;.&quot;
            set i2a_map[47]  = &quot;/&quot;
            set i2a_map[48]  = &quot;0&quot;
            set i2a_map[49]  = &quot;1&quot;
            set i2a_map[50]  = &quot;2&quot;
            set i2a_map[51]  = &quot;3&quot;
            set i2a_map[52]  = &quot;4&quot;
            set i2a_map[53]  = &quot;5&quot;
            set i2a_map[54]  = &quot;6&quot;
            set i2a_map[55]  = &quot;7&quot;
            set i2a_map[56]  = &quot;8&quot;
            set i2a_map[57]  = &quot;9&quot;
            set i2a_map[58]  = &quot;:&quot;
            set i2a_map[59]  = &quot;;&quot;
            set i2a_map[60]  = &quot;&lt;&quot;
            set i2a_map[61]  = &quot;=&quot;
            set i2a_map[62]  = &quot;&gt;&quot;
            set i2a_map[63]  = &quot;?&quot;
            set i2a_map[64]  = &quot;@&quot;
            set i2a_map[65]  = &quot;A&quot;
            set i2a_map[66]  = &quot;B&quot;
            set i2a_map[67]  = &quot;C&quot;
            set i2a_map[68]  = &quot;D&quot;
            set i2a_map[69]  = &quot;E&quot;
            set i2a_map[70]  = &quot;F&quot;
            set i2a_map[71]  = &quot;G&quot;
            set i2a_map[72]  = &quot;H&quot;
            set i2a_map[73]  = &quot;I&quot;
            set i2a_map[74]  = &quot;J&quot;
            set i2a_map[75]  = &quot;K&quot;
            set i2a_map[76]  = &quot;L&quot;
            set i2a_map[77]  = &quot;M&quot;
            set i2a_map[78]  = &quot;N&quot;
            set i2a_map[79]  = &quot;O&quot;
            set i2a_map[80]  = &quot;P&quot;
            set i2a_map[81]  = &quot;Q&quot;
            set i2a_map[82]  = &quot;R&quot;
            set i2a_map[83]  = &quot;S&quot;
            set i2a_map[84]  = &quot;T&quot;
            set i2a_map[85]  = &quot;U&quot;
            set i2a_map[86]  = &quot;V&quot;
            set i2a_map[87]  = &quot;W&quot;
            set i2a_map[88]  = &quot;X&quot;
            set i2a_map[89]  = &quot;Y&quot;
            set i2a_map[90]  = &quot;Z&quot;
            set i2a_map[91]  = &quot;[&quot;
            set i2a_map[92]  = &quot;\\&quot;
            set i2a_map[93]  = &quot;]&quot;
            set i2a_map[94]  = &quot;^&quot;
            set i2a_map[95]  = &quot;_&quot;
            set i2a_map[96]  = &quot;`&quot;
            set i2a_map[97]  = &quot;a&quot;
            set i2a_map[98]  = &quot;b&quot;
            set i2a_map[99]  = &quot;c&quot;
            set i2a_map[100] = &quot;d&quot;
            set i2a_map[101] = &quot;e&quot;
            set i2a_map[102] = &quot;f&quot;
            set i2a_map[103] = &quot;g&quot;
            set i2a_map[104] = &quot;h&quot;
            set i2a_map[105] = &quot;i&quot;
            set i2a_map[106] = &quot;j&quot;
            set i2a_map[107] = &quot;k&quot;
            set i2a_map[108] = &quot;l&quot;
            set i2a_map[109] = &quot;m&quot;
            set i2a_map[110] = &quot;n&quot;
            set i2a_map[111] = &quot;o&quot;
            set i2a_map[112] = &quot;p&quot;
            set i2a_map[113] = &quot;q&quot;
            set i2a_map[114] = &quot;r&quot;
            set i2a_map[115] = &quot;s&quot;
            set i2a_map[116] = &quot;t&quot;
            set i2a_map[117] = &quot;u&quot;
            set i2a_map[118] = &quot;v&quot;
            set i2a_map[119] = &quot;w&quot;
            set i2a_map[120] = &quot;x&quot;
            set i2a_map[121] = &quot;y&quot;
            set i2a_map[122] = &quot;z&quot;
            set i2a_map[123] = &quot;{&quot;
            set i2a_map[124] = &quot;|&quot;
            set i2a_map[125] = &quot;}&quot;
            set i2a_map[126] = &quot;~&quot;

        endmethod
    endmodule

    struct i2a_loader_dummy
        implement i2a_loader
    endstruct

    function ModuloInt takes integer h, integer b returns integer
        return h - (h / b) * b
    endfunction

    function sub_I2A takes nothing returns nothing
        if i2a_integer &lt; 0x100 then
            set i2a_string = i2a_map[ModuloInt(i2a_integer, 0x100)]
        else
            set i2a_string = i2a_map[i2a_integer / 0x1000000]                 + /*
                          */ i2a_map[ModuloInt(i2a_integer / 0x10000, 0x100)] + /*
                          */ i2a_map[ModuloInt(i2a_integer / 0x100, 0x100)]   + /*
                          */ i2a_map[ModuloInt(i2a_integer, 0x100)] 
        endif
    endfunction

    function I2A takes integer i returns string
        set i2a_integer = i
        call ExecuteFunc(&quot;sub_I2A&quot;)
        return i2a_string
    endfunction

endlibrary

globals
    integer tms_max_value_index    = 0
    integer tms_min_value_index    = 0
    integer tms_iiii               = 0
    integer tms_jjjj               = 0
    string  tms_array_str          = &quot;&quot;
    group   tms_gggg               = CreateGroup()
    integer array CHAR2INT

    integer      tms_copy_of_ith_number         = 0
    string       tms_copy_of_ith_string         = &quot;&quot;
    unit         tms_copy_of_ith_unit           = null
    item         tms_copy_of_ith_item           = null
    destructable tms_copy_of_ith_destructable   = null
    
    // if you need to sort type x then you need
    // to modify the next line with the type of the
    // variable:
    // x tms_copy_of_ith_x = null
    // replace the &quot;x&quot;s with your type
endglobals

//! textmacro sort_numbers_asc takes ARRAY_NAME, INDEX_A, INDEX_B
set tms_iiii = $INDEX_A$
loop
    exitwhen tms_iiii &gt;= $INDEX_B$
    set tms_min_value_index = tms_iiii
    set tms_jjjj = tms_iiii + 1
    loop
        exitwhen tms_jjjj &gt;= $INDEX_B$
        if $ARRAY_NAME$[tms_min_value_index] &gt; $ARRAY_NAME$[tms_jjjj] then
            set tms_min_value_index = tms_jjjj
        endif
        set tms_jjjj = tms_jjjj + 1
    endloop
    set tms_copy_of_ith_number = $ARRAY_NAME$[tms_iiii]
    set $ARRAY_NAME$[tms_iiii] = $ARRAY_NAME$[tms_min_value_index]
    set $ARRAY_NAME$[tms_min_value_index] = tms_copy_of_ith_number

    set tms_iiii = tms_iiii + 1
endloop
//! endtextmacro

//! textmacro sort_numbers_desc takes ARRAY_NAME, INDEX_A, INDEX_B
set tms_iiii = $INDEX_A$
loop
    exitwhen tms_iiii &gt;= $INDEX_B$
    set tms_max_value_index = tms_iiii
    set tms_jjjj = tms_iiii + 1
    loop
        exitwhen tms_jjjj &gt;= $INDEX_B$
        if $ARRAY_NAME$[tms_max_value_index] &lt; $ARRAY_NAME$[tms_jjjj] then
            set tms_max_value_index = tms_jjjj
        endif
        set tms_jjjj = tms_jjjj + 1
    endloop
    set tms_copy_of_ith_number = $ARRAY_NAME$[tms_iiii]
    set $ARRAY_NAME$[tms_iiii] = $ARRAY_NAME$[tms_max_value_index]
    set $ARRAY_NAME$[tms_max_value_index] = tms_copy_of_ith_number

    set tms_iiii = tms_iiii + 1
endloop
//! endtextmacro

function lexicographical_order takes string s1, string s2 returns boolean
    local integer len_s1  = StringLength(s1)
    local integer len_s2  = StringLength(s2)
    local integer p       = 0
    local integer shorter = 0
    local integer ord_ch1 = 0
    local integer ord_ch2 = 0

    if len_s1 &gt; len_s2 then
        set shorter = len_s2
    else
        set shorter = len_s1
    endif

    loop
        exitwhen p &gt;= shorter

        set ord_ch1 = A2I(SubString(s1, p, p + 1))
        set ord_ch2 = A2I(SubString(s2, p, p + 1))
        if  ord_ch1 &gt; ord_ch2 then
            return true
        elseif ord_ch1 &lt; ord_ch2 then
            return false
        endif

        set p = p + 1
    endloop
    
    if len_s1 == shorter then
        return false
    endif

    return true
endfunction

//! textmacro sort_strings_asc takes ARRAY_NAME, INDEX_A, INDEX_B
set tms_iiii = $INDEX_A$
loop
    exitwhen tms_iiii &gt;= $INDEX_B$
    set tms_min_value_index = tms_iiii
    set tms_jjjj = tms_iiii + 1
    loop
        exitwhen tms_jjjj &gt;= $INDEX_B$
        if lexicographical_order($ARRAY_NAME$[tms_min_value_index], $ARRAY_NAME$[tms_jjjj]) then
            set tms_min_value_index = tms_jjjj
        endif
        set tms_jjjj = tms_jjjj + 1
    endloop
    set tms_copy_of_ith_string = $ARRAY_NAME$[tms_iiii]
    set $ARRAY_NAME$[tms_iiii] = $ARRAY_NAME$[tms_min_value_index]
    set $ARRAY_NAME$[tms_min_value_index] = tms_copy_of_ith_string

    set tms_iiii = tms_iiii + 1
endloop
//! endtextmacro

//! textmacro sort_strings_desc takes ARRAY_NAME, INDEX_A, INDEX_B
set tms_iiii = $INDEX_A$
loop
    exitwhen tms_iiii &gt;= $INDEX_B$
    set tms_max_value_index = tms_iiii
    set tms_jjjj = tms_iiii + 1
    loop
        exitwhen tms_jjjj &gt;= $INDEX_B$
        if not lexicographical_order($ARRAY_NAME$[tms_max_value_index], $ARRAY_NAME$[tms_jjjj]) then
            set tms_max_value_index = tms_jjjj
        endif
        set tms_jjjj = tms_jjjj + 1
    endloop
    set tms_copy_of_ith_string = $ARRAY_NAME$[tms_iiii]
    set $ARRAY_NAME$[tms_iiii] = $ARRAY_NAME$[tms_max_value_index]
    set $ARRAY_NAME$[tms_max_value_index] = tms_copy_of_ith_string

    set tms_iiii = tms_iiii + 1
endloop
//! endtextmacro

//! textmacro sort_handles_asc takes ARRAY_NAME, INDEX_A, INDEX_B, COMPARISION_FUNCTION_NAME, HANDLE_TYPE
set tms_iiii = $INDEX_A$
loop
    exitwhen tms_iiii &gt;= $INDEX_B$
    set tms_min_value_index = tms_iiii
    set tms_jjjj = tms_iiii + 1
    loop
        exitwhen tms_jjjj &gt;= $INDEX_B$
        if $COMPARISION_FUNCTION_NAME$($ARRAY_NAME$[tms_min_value_index], $ARRAY_NAME$[tms_jjjj]) then
            set tms_min_value_index = tms_jjjj
        endif
        set tms_jjjj = tms_jjjj + 1
    endloop
    set tms_copy_of_ith_$HANDLE_TYPE$ = $ARRAY_NAME$[tms_iiii]
    set $ARRAY_NAME$[tms_iiii] = $ARRAY_NAME$[tms_min_value_index]
    set $ARRAY_NAME$[tms_min_value_index] = tms_copy_of_ith_$HANDLE_TYPE$
    
    set tms_iiii = tms_iiii + 1
endloop
set tms_copy_of_ith_$HANDLE_TYPE$ = null
//! endtextmacro

//! textmacro sort_handles_desc takes ARRAY_NAME, INDEX_A, INDEX_B, COMPARISION_FUNCTION_NAME, HANDLE_TYPE
set tms_iiii = $INDEX_A$
loop
    exitwhen tms_iiii &gt;= $INDEX_B$
    set tms_max_value_index = tms_iiii
    set tms_jjjj = tms_iiii + 1
    loop
        exitwhen tms_jjjj &gt;= $INDEX_B$
        if not $COMPARISION_FUNCTION_NAME$($ARRAY_NAME$[tms_max_value_index], $ARRAY_NAME$[tms_jjjj]) then
            set tms_max_value_index = tms_jjjj
        endif
        set tms_jjjj = tms_jjjj + 1
    endloop
    set tms_copy_of_ith_$HANDLE_TYPE$ = $ARRAY_NAME$[tms_iiii]
    set $ARRAY_NAME$[tms_iiii] = $ARRAY_NAME$[tms_max_value_index]
    set $ARRAY_NAME$[tms_max_value_index] = tms_copy_of_ith_$HANDLE_TYPE$
    
    set tms_iiii = tms_iiii + 1
endloop
set tms_copy_of_ith_$HANDLE_TYPE$ = null
//! endtextmacro

// required by the say_a function/textmacro to print arrays of string type =)
function S2S takes string s returns string
    return s
endfunction

//! textmacro say_a takes ARRAY_NAME, INDEX_A, INDEX_B, TO_STRING
set tms_array_str = &quot;&quot;
set tms_iiii = $INDEX_A$
loop
    exitwhen tms_iiii &gt;= $INDEX_B$
    set tms_array_str = tms_array_str + $TO_STRING$($ARRAY_NAME$[tms_iiii]) + &quot;, &quot;
    set tms_iiii = tms_iiii + 1
endloop
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, &quot;[&quot; + SubString(tms_array_str, 0, StringLength(tms_array_str) - 2) + &quot;]&quot;)
//! endtextmacro

//! textmacro group2array takes GROUP, ARRAY
call GroupClear(tms_gggg)
set tms_iiii = 0
set tms_copy_of_ith_unit = FirstOfGroup($GROUP$)
loop
    exitwhen tms_copy_of_ith_unit == null
    call GroupAddUnit(tms_gggg, tms_copy_of_ith_unit)
    set $ARRAY$[tms_iiii] = tms_copy_of_ith_unit
    set tms_iiii = tms_iiii + 1   
    set tms_copy_of_ith_unit = FirstOfGroup($GROUP$)
endloop
set $GROUP$ = tms_gggg
//! endtextmacro


Example how to use:
JASS:
globals
    integer array Arry
    unit    array Units
    string  array Lang 
endglobals

function comp_unit_hp takes unit u1, unit u2 returns boolean
    return GetWidgetLife(u1) &gt; GetWidgetLife(u2)
endfunction

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    local integer a_inc = 0
    local integer b_excl = 4
    local integer lang_count = 25
    
    //! runtextmacro say_a(&quot;Arry&quot;, &quot;a_inc&quot;, &quot;b_excl&quot;, &quot;I2S&quot;)
    //! runtextmacro sort_numbers_asc(&quot;Arry&quot;, &quot;a_inc&quot;, &quot;b_excl&quot;)
    //! runtextmacro say_a(&quot;Arry&quot;, &quot;a_inc&quot;, &quot;b_excl&quot;, &quot;I2S&quot;)
    //! runtextmacro sort_numbers_desc(&quot;Arry&quot;, &quot;a_inc&quot;, &quot;b_excl&quot;)
    //! runtextmacro say_a(&quot;Arry&quot;, &quot;a_inc&quot;, &quot;b_excl&quot;, &quot;I2S&quot;)

    //! runtextmacro say_a(&quot;Units&quot;, &quot;0&quot;, &quot;4&quot;, &quot;GetUnitName&quot;)
    //! runtextmacro sort_handles_asc(&quot;Units&quot;, &quot;0&quot;, &quot;4&quot;, &quot;comp_unit_hp&quot;, &quot;unit&quot;)
    //! runtextmacro say_a(&quot;Units&quot;, &quot;0&quot;, &quot;4&quot;, &quot;GetUnitName&quot;)
    //! runtextmacro sort_handles_desc(&quot;Units&quot;, &quot;0&quot;, &quot;4&quot;, &quot;comp_unit_hp&quot;, &quot;unit&quot;)
    //! runtextmacro say_a(&quot;Units&quot;, &quot;0&quot;, &quot;4&quot;, &quot;GetUnitName&quot;)
    
    //! runtextmacro say_a(&quot;Lang&quot;, &quot;0&quot;, &quot;lang_count&quot;, &quot;S2S&quot;)
    //! runtextmacro sort_strings_asc(&quot;Lang&quot;, &quot;0&quot;, &quot;lang_count&quot;)
    //! runtextmacro say_a(&quot;Lang&quot;, &quot;0&quot;, &quot;lang_count&quot;, &quot;S2S&quot;)
    //! runtextmacro sort_strings_desc(&quot;Lang&quot;, &quot;0&quot;, &quot;lang_count&quot;)
    //! runtextmacro say_a(&quot;Lang&quot;, &quot;0&quot;, &quot;lang_count&quot;, &quot;S2S&quot;)
    
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set Arry[0] = 1
    set Arry[1] = 0
    set Arry[2] = 2
    set Arry[3] = 3

    set Units[0] = CreateUnit(Player(0), &#039;hfoo&#039;, 0, 0, 0)
    set Units[1] = CreateUnit(Player(0), &#039;ogru&#039;, 0, 0, 0)
    set Units[2] = CreateUnit(Player(0), &#039;hpea&#039;, 0, 0, 0)
    set Units[3] = CreateUnit(Player(0), &#039;otau&#039;, 0, 0, 0)
    
    set Lang[0]   = &quot;FORTRAN&quot;
    set Lang[1]   = &quot;Pascal&quot;
    set Lang[2]   = &quot;C&quot;
    set Lang[3]   = &quot;Perl&quot;
    set Lang[4]   = &quot;C++&quot;
    set Lang[5]   = &quot;Perl 6 =)&quot;
    set Lang[6]   = &quot;JavaScript&quot;
    set Lang[7]   = &quot;C#&quot;
    set Lang[8]   = &quot;Java&quot;
    set Lang[9]  = &quot;Delphi&quot;
    set Lang[10]  = &quot;Phyton&quot;
    set Lang[11]  = &quot;Galaxy Script&quot;
    set Lang[12]  = &quot;Andromeda&quot;
    set Lang[13]  = &quot;vim script&quot;
    set Lang[14]  = &quot;Bash&quot;
    set Lang[15]  = &quot;XML&quot;
    set Lang[16]  = &quot;unrealscript&quot;
    set Lang[17]  = &quot;E-Prime&quot;
    set Lang[18]  = &quot;Prolog&quot;
    set Lang[19]  = &quot;Mathematics&quot;
    set Lang[20]  = &quot;Hanguel&quot;
    set Lang[21]  = &quot;Asembly&quot;
    set Lang[22]  = &quot;vJass&quot;
    set Lang[23]  = &quot;Php&quot;
    set Lang[24]  = &quot;Blizzard&#039;s Warcraft 3 GUI&quot;

    set gg_trg_Untitled_Trigger_001 = CreateTrigger()
    call TriggerRegisterPlayerEventEndCinematic( gg_trg_Untitled_Trigger_001, Player(0))
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )

    call BJDebugMsg(I2S(A2I(&quot;A&quot;)))
endfunction


Example using the powerfull jass preprocessor called cJass =).
JASS:
#define sort_numbers_asc_(x, a, b)        = //! runtextmacro sort_numbers_asc(x, a, b)
#define sort_numbers_desc_(x, a, b)       = //! runtextmacro sort_numbers_desc(x, a, b)

#define sort_strings_asc_(x, a, b)        = //! runtextmacro sort_strings_asc(x, a, b)
#define sort_strings_desc_(x, a, b)       = //! runtextmacro sort_strings_desc(x, a, b)

#define sort_handles_asc_(x, a, b, f, t)  = //! runtextmacro sort_handles_asc(x, a, b, f, t)
#define sort_handles_desc_(x, a, b, f, t) = //! runtextmacro sort_handles_desc(x, a, b, f, t)

#define say_a_(x, a, b)                   = //! runtextmacro say_a(x, a, b)
#define group2array_(g, a)                = //! runtextmacro group2array(g, a)

integer array Arry
unit    array Units
string  array Lang 

bool comp_unit_hp(unit u1, unit u2)
{
    return GetWidgetLife(u1) &gt; GetWidgetLife(u2)
}

void Trig_Untitled_Trigger_001_Actions()
{
    integer a_inc = 0
    integer b_excl = 4
    integer lang_count = 25
    
    say_a(Arry, a_inc, b_excl, I2S)
    sort_numbers_asc(Arry, a_inc, b_excl)
    say_a(Arry, a_inc, b_excl, I2S)
    sort_numbers_desc(Arry, a_inc, b_excl)
    say_a(Arry, a_inc, b_excl, I2S)

    say_a(Units, 0, 4, GetUnitName)
    sort_handles_asc(Units, 0, 4, comp_unit_hp, unit)
    say_a(Units, 0, 4, GetUnitName)
    sort_handles_desc(Units, 0, 4, comp_unit_hp, unit)
    say_a(Units, 0, 4, GetUnitName)
    
    say_a(Lang, 0, lang_count, S2S)
    sort_strings_asc(Lang, 0, lang_count)
    say_a(Lang, 0, lang_count, S2S)
    sort_strings_desc(Lang, 0, lang_count)
    say_a(Lang, 0, lang_count, S2S)
}

//------------------------------------------------------------------
void InitTrig_Untitled_Trigger_001()
{
    Arry[0] = 1
    Arry[1] = 0
    Arry[2] = 2
    Arry[3] = 3

    Units[0] = CreateUnit(Player(0), &#039;hfoo&#039;, 0, 0, 0)
    Units[1] = CreateUnit(Player(0), &#039;ogru&#039;, 0, 0, 0)
    Units[2] = CreateUnit(Player(0), &#039;hpea&#039;, 0, 0, 0)
    Units[3] = CreateUnit(Player(0), &#039;otau&#039;, 0, 0, 0)
    
    Lang[0]   = &quot;FORTRAN&quot;
    Lang[1]   = &quot;Pascal&quot;
    Lang[2]   = &quot;C&quot;
    Lang[3]   = &quot;Perl&quot;
    Lang[4]   = &quot;C++&quot;
    Lang[5]   = &quot;Perl 6 =)&quot;
    Lang[6]   = &quot;JavaScript&quot;
    Lang[7]   = &quot;C#&quot;
    Lang[8]   = &quot;Java&quot;
    Lang[9]   = &quot;Delphi&quot;
    Lang[10]  = &quot;Phyton&quot;
    Lang[11]  = &quot;Galaxy Script&quot;
    Lang[12]  = &quot;Andromeda&quot;
    Lang[13]  = &quot;vim script&quot;
    Lang[14]  = &quot;Bash&quot;
    Lang[15]  = &quot;XML&quot;
    Lang[16]  = &quot;unrealscript&quot;
    Lang[17]  = &quot;E-Prime&quot;
    Lang[18]  = &quot;Prolog&quot;
    Lang[19]  = &quot;Mathematics&quot;
    Lang[20]  = &quot;Hanguel&quot;
    Lang[21]  = &quot;Asembly&quot;
    Lang[22]  = &quot;vJass&quot;
    Lang[23]  = &quot;Php&quot;
    Lang[24]  = &quot;Blizzard&#039;s Warcraft 3 GUI&quot;

    gg_trg_Untitled_Trigger_001 = CreateTrigger()
    TriggerRegisterPlayerEventEndCinematic( gg_trg_Untitled_Trigger_001, Player(0))
    TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )

    BJDebugMsg(I2S(A2I(&quot;A&quot;)))
}
 

Dirac

22710180
Reaction score
147
This has the worst API ever
This sorting method is by far the slowest method, so slow it's very noticeable in wc3
Nestharus already made lots of sorting systems and so have I (not as efficient, but still useful).
So far none of your resources have been useful, you might want to improve your methods
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Dirac:
1. This sorting method is by far the slowest method, so slow it's very noticeable in wc3
2. Nestharus already made lots of sorting systems and so have I (not as efficient, but still useful).
3. So far none of your resources have been useful, you might want to improve your methods
4. This has the worst API ever

1. Can you give me a test in which this sorting method will slow wc3 noticeably?
2. Links?
3. Can you elaborate/give details more on that point?
4. What is that you don't like about it?
 

Dirac

22710180
Reaction score
147
1. List of sorting algorithms ordered by (i think) speed http://en.wikipedia.org/wiki/Sorting_algorithm#Summaries_of_popular_sorting_algorithms
2. http://www.thehelper.net/forums/showthread.php/167213-AVL-Tree
http://www.thehelper.net/forums/showthread.php/166444-MergeList
http://www.thehelper.net/forums/showthread.php/167233-QuickSort-Integer
http://www.thehelper.net/forums/showthread.php/165890-Minimum-Binary-Heap
3. I reffer to your 4d array, which didn't work properly, tods splits and joins, which isn't really a resource, and now this
4. It uses a textmacro and you don't even explain where to put it, it takes more values than it should. IMO this resource should be a textmacro that sorts an array using quicksort, it should take the array's name and it's size. the textmacro should be placed anywhere inside a funcion.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
1. cJass is not supported here.

2. Is your example trigger combined with your system?

3. Why did you choose to name some of your functions "Untitled_Trigger_001" which will conflict with any new unnamed triggers people create?

4. Where is the system's explanation and example trigger?

5. What/where is the interface to use the system? FYI, Textmacros are one of the worst interfaces you can make available, and thus should only be used sparingly, and usually only for non-public interfaces.

6. Why is this all in the global space? Put it in a library and make private what should be private.

7. As said above, why selection sort? It's a terribly inefficient method.

Graveyarded.
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Dirac:
1. 1. List of sorting algorithms ordered by (i think) speed
2. http://www.thehelper.net/forums/show...67213-AVL-Tree, http://www.thehelper.net/forums/show...um-Binary-Heap
3. http://www.thehelper.net/forums/show...6444-MergeList, http://www.thehelper.net/forums/show...ckSort-Integer
4. I reffer to your 4d array, which didn't work properly
5. tods splits and joins, which isn't really a resource,
6. IMO this resource should be a textmacro that sorts an array using quicksort,
7. it should take the array's name and it's size.
8. It uses a textmacro and you don't even explain where to put it

1. That's not what my 1st question was about.
2. Those are not sorting algorithms/methods, but data structures AVL, Binary-Heap,
3. Those two cannot sort arbitrary arrays and they sort only in ascending order.
4. Wait what? How didn't it not work?
5. What is your definition of a resource?
6. I used Selection Sort because it's easy to implement both ascending and descending sorting
(in wc3 it's really unlike to use sorting for arrays of 200+ size, more likely to sort on average
arrays with size < 50, with those cases the added complexity of quicksort compared to its minor speed
advantage [if any] doesn't worth it.)
7. Taking a range [a, b] is really better than taking just size, this allows to sort part of the array. (and how hard is to use "0", "size - 1")
8. You want an explanation of where to place textmacros (Isn't it obvious)?
Even if someone has never used textmacros it pretty easy to see from the example.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
6. I used Selection Sort because it's easy to implement both ascending and descending sorting
(in wc3 it's really unlike to use sorting for arrays of 200+ size, more likely to sort on average
arrays with size < 50, with those cases the added complexity of quicksort compared to its minor speed
advantage [if any] doesn't worth it.)

size = 50 for an n^2 algorithm is at best case 2500 operations. size = 50 for an n*log(n) algorithm with log base 2 is at best 300 operations. The "added complexity" is unlikely to be such large difference in speed. Even with a size n = 8, the n^2 algorithm is at best 64 operations, while the n*log(n) algorithm with log base 2 is at best 24 operations.

EDIT: Also, doing ascending/descending sorting is as simple as reversing the array, an O(n) operation that doesn't change the complexity of any sorting method.

8. You want an explanation of where to place textmacros (Isn't it obvious)?
Even if someone has never used textmacros it pretty easy to see from the example.

It's not very obvious, no. I don't know what the "say_a" textmacro is supposed to mean, much less why sometimes you pass I2S or GetUnitName functions at different times, or what the purpose of the a, b, c, d integers is. I think only the "Arry" part of it is even the least bit self explanatory.
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Darthfett:
1. cJass is not supported here. (Romek: cJass resources are not supported nor allowed here at Thehelper.net.
This is due to the code being messy and the fact that it needs an additional tool to compile.
Also, vJass and Zinc have virtually all the features of cJass, but are easier to use, and far more standardised.)
2. Is your example trigger combined with your system?
3. Why did you choose to name some of your functions "Untitled_Trigger_001" which will conflict with any new unnamed triggers people create?
4. Where is the system's explanation and example trigger?
5. What/where is the interface to use the system? FYI, Textmacros are one of the worst interfaces you can make available, and thus should only be used sparingly, and usually only for non-public interfaces.
6. Why is this all in the global space? Put it in a library and make private what should be private.
7. As said above, why selection sort? It's a terribly inefficient method.
8. Graveyarded.
9. It's not very obvious, no.
10. or what the purpose of the a, b, c, d integers is.

1. the code being messy (I have zero idea of what that's supposed to mean, cjass makes
jass part of the C family of languages, so if Romek thinks that C like languages are messy that's his personal opinion),
cjass has the easiest installer in I've seen and I really think that having more tools (useful) is always better.
2. It was.
3. What can I say, "Untitled_Trigger_001" is my favourite function naming convention, and of course
InitTrig_Untitled_Trigger_001, Trig_Untitled_Trigger_001_Actions are my favourite function names after "say" of course =).
4. Yeah you are right sorting need explanation, that's why I will link to the wiki page about sorting. The example trigger
is there now as it was before.
5. It obvious from the example what the interface is (No?).
6. Nothing should be private.
7. See above my explanation why.
8. Because?
9. Well I am sorry then, you should read the jasshelper manual for more information.
10. to demonstrate that variable ranges can be specified (not just integer literals like: "0", "3")
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Darthfett:
1. cJass is not supported here. (Romek: cJass resources are not supported nor allowed here at Thehelper.net.
This is due to the code being messy and the fact that it needs an additional tool to compile.
Also, vJass and Zinc have virtually all the features of cJass, but are easier to use, and far more standardised.)
2. Is your example trigger combined with your system?
3. Why did you choose to name some of your functions "Untitled_Trigger_001" which will conflict with any new unnamed triggers people create?
4. Where is the system's explanation and example trigger?
5. What/where is the interface to use the system? FYI, Textmacros are one of the worst interfaces you can make available, and thus should only be used sparingly, and usually only for non-public interfaces.
6. Why is this all in the global space? Put it in a library and make private what should be private.
7. As said above, why selection sort? It's a terribly inefficient method.
8. Graveyarded.
9. It's not very obvious, no.
10. or what the purpose of the a, b, c, d integers is.

1. the code being messy (I have zero idea of what that's supposed to mean, cjass makes
jass part of the C family of languages, so if Romek thinks that C like languages are messy that's his personal opinion),
cjass has the easiest installer in I've seen and I really think that having more tools (useful) is always better.

...

8. Because?

This is the agreed upon rules by the staff. Just because one person posted the rules, doesn't mean it's only his opinion. This is the reason your system is graveyarded. cJass usually makes code messy, because it allows programmers to be sloppy.

9. Well I am sorry then, you should read the jasshelper manual for more information.

My intention was not to say "I don't know how to program vJass" or how to use textmacros. My intention was to say that you need to document HOW to use it. I can figure it out if I read your code, but why should I have to read your code to use it? Systems should be able to be used by reading the documentation, NOT from reading the code.
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Darthfett:
1.This is the reason your system is graveyarded. cJass usually makes code messy, because it allows programmers to be sloppy.
2. I can figure it out if I read your code, but why should I have to read your code to use it?
3. Systems should be able to be used by reading the documentation, NOT from reading the code.

1. Give me 1 example, just 1 example.
2. Well I think reading example code helps for figuring out how to use something. (learn by example).
3. This is not a system its 4 sorting routines and 1 printing.
 

Dirac

22710180
Reaction score
147
1. Give me 1 example, just 1 example.
>http://www.thehelper.net/forums/showthread.php/167517-textmacro-sort
2. Well I think reading example code helps for figuring out how to use something. (learn by example).
>True, but you as a provider should explain the code without forcing people to read it
3. This is not a system its 4 sorting routines and 1 printing.
>Same as above

There are lots of reasons of why is this graveyarded and my favorite is that it's using bubble sort. There are other way way faster methods to sort things, and to change to those you would have to rewrite the whole resource.
I agree with darthfett in every single point he stated
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Dirac:
1. There are lots of reasons of why is this graveyarded and my favorite is that it's using bubble sort.
2. True, but you as a provider should explain the code without forcing people to read it
3. Same as above
4. http://www.thehelper.net/forums/show...textmacro-sort
5. I agree with darthfett in every single point he stated

1. I don't even want to comment on this one...
2. Explain how sorting works?... And I've never force anyone to read my code (how can I?), I just point that if someone doesn't understand how
to use something he could just look at the example.
3. ???
4. What can I say... the cjass looks much better:

[ljass] //! runtextmacro sort_array_asc("Arry", "c", "d") [/ljass]

vs

[ljass] sort_array_asc(Arry, c, d) [/ljass]

So this actually demonstrates how cjass makes code a lot less messier.
Thank you for that =).

5. I think all of your points stated are arguable wrong, or just plain senseless (except the speed one).
 

Dirac

22710180
Reaction score
147
>Ugly Programming
Who on earth wants that?!
first of all: the sole reason that your favorite function name is "Untitled_Trigger_001" makes me wanna kill puppies, lots of them. Why?
It IS NOT NEAT, it's like posting your whole on binary code, i would even prefer reading Nestharus's "puzzles" snippets and systems over functions with these names.
Same thing goes to global variables named like these [ljass]integer tms_jjjj[/ljass]. Why are you doing this? couldnt you just name it [ljass]public integer J[/ljass] and put it inside a library? Textmacro names shouldn't be [ljass]//! textmacro ugly_texmacro_a[/ljass], instead something like [ljass]//! textmacro PrintArray[/ljass]. encapsulation is one of the great things vJass provides and the main reason of it's existence is to make the code look better, more readable. You can't submit a resource for others to use if you don't care whatsoever of how it looks.

According to the response you made to my post you think my points are wrong, if you really think that then no one in this forums can help you improve this horrible way of programming because you're closing yourself to something that no one wants.

The first thing i did when i started learning vJass was to learn how people order their code in order to make it more legible, and i still do.
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Dirac:
1. Ugly Programming. Who on earth wants that?!
first of all: the sole reason that your favorite function name is "Untitled_Trigger_001" makes me wanna kill puppies, lots of them. Why?
It IS NOT NEAT
2. Same thing goes to global variables named like these integer tms_jjjj. Why are you doing this? couldnt you just name it public integer J and put it inside a library?
3. Textmacro names shouldn't be //! textmacro ugly_texmacro_a, instead something like //! textmacro PrintArray.
4. You can't submit a resource for others to use if you don't care whatsoever of how it looks.
5. According to the response you made to my post you think my points are wrong

1. Obviously someone forgot his sense of humor when he got out of bed.
2. The virable names are picked to protect from collisions with user defined ones. It's just the same if I call the library tms and make them public or just name them by hand.
3. Well that's your opinion what's "ugly" and what's not. (You know that you can acutally rename (it's not like there are 500 textmacros) them? Yeah ... imagine that.)
4. If I didn't care ("whatsoever") how the code looks I wouldn't use indentation and would call my variables with senseless short names.
5. Most of them are:

Dirac:
(X means not true, ? means the statement lacks evidence)
I reffer to your 4d array, which didn't work properly -> X (I asked you where did you find that it doesn't work, and it works perfectly fine)
There are lots of reasons of why is this graveyarded and my favorite is that it's using bubble sort. -> X (It acutally uses Selection Sort as stated in the 1st post)
True, but you as a provider should explain the code without forcing people to read it -> X (As I stated above I havn't/won't "force" anybody to read my code)
List of sorting algorithms ordered by (i think) speed -> X (AVL and BH as stated above are not sorting algorithms)
So far none of your resources have been useful, you might want to improve your methods -> ? (I asked you "Can you elaborate/give details more on that point?" but you didn't answer, and something being not useful to you doesn't nesseserily mean that it's completly useless to everyone else.)
 

tooltiperror

Super Moderator
Reaction score
231
Can you please stop formatting your posts like that? They are more difficult to read than they should be. Use [NOPARSE][/NOPARSE] or a > character instead.
 

NoobImbaPro

You can change this now in User CP.
Reaction score
60
*makes me wanna kill puppies, lots of them.

you better kill puppets, let puppies live.

As about cJass, I believe we have enough zinc witch is a c/p of C programming...
So adding cJass in the forum is inconceivable.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top