Originally Posted by
Niminae
I'm not sure if that was a deadpan snark or not. Text just doesn't convey that well at all. Remember all of the really embarrassing (or at least they should have been seen as such) typos and grammatical errors that used to exist all over the place? .
Exactly.
Originally Posted by
Gremmlynn
To me it just sounds like they put the lowly (or possibly un-) paid intern on some scut work they didn't feel was worth paying others more to do. Kind of like not hiring a lawyer to clean your pool due to what you have to pay a lawyer an hour to do anything. My guess is that they simply pay programmers more than what they feel correcting typos is worth.
This is a terrible analogy. The lawyer has no professional pride in the cleanness of the pool. It's more like formatting errors in a legal document, with the lawyers name on it. *technically* he's paid on results, professional pride should drive him to clean up the **** in his environment. He should do it WITHOUT being told to do it.
Originally Posted by
Niminae
Sorting in bash, or via SED or AWK, is also trivial. In bash you use *gasp* 'sort' plus command line arguments.
Absolutely right, I love nerd technicalities. I fear, however, we have gone the other way in the "sort" discussion from above where everyone was trying to make it the most complicated sort problem possible (somehow multiple languages, hardwares, rolling own sorts, infinite dynamic lists of unknown data) - and we have boiled it down to "sort anything on any parameter".
For fun - assembly sort (note - stolen, referenced, and I didn't really read it or verify it)
https://www.quora.com/What-is-the-co...rt-in-assembly
Code:
selection_sort_i64:
; /*
; Input:
; RDI = long long * array
; RSI = length
;
; Pseudo-C code:
;
; for (int i = 0; i < n - 1; ++i) {
; min = i
; for (int j = i + 1; j < n; ++j) {
; if a[j] < a[min]; min = j
; swap(i, min)
;*/
I64_SIZE equ 8
LG_I64_SIZE equ 3
cmp rsi, 1
jle .end ; Just end it if length <= 1
xchg rsi, rdi ; rsi => left pointer
mov rcx, rdi ; rcx => length
; RDX will be the boundary for i: RSI + (N-1)*sizeof(int64)
lea rdx, [rsi + rcx * LL_SIZE - LL_SIZE]
; /*
; Let's explain what's happening here.
; RSI will be &a[i], RDX will be it's right boundary
; RDI will be &a[j] (&a[i + 1]) and will loop n-i times
; RCX will be n-i and will be the counter for the inner loop
; RAX will track our minimum in the remaining of the array
; RBX will
; */
.outer_loop:
cmp rsi, rdx
jge .end ; while (i < n - 1) {
mov rax, [rsi] ; min = a[i]
mov rbx, rsi ; min_i = i
push rax
mov rdi, rsi
add rdi, I64_SIZE ; j = i + 1 // rdi => right pointer
dec rcx ; // rcx = n - i, inner loop counter
push rcx
.inner_loop:
cmp rax, [rdi] ; if (min > a[j])
jle .min_less_or_equal
mov rbx, rdi ; min_i = j
mov rax, [rdi] ; min = a[j]
.min_less_or_equal:
add rdi, I64_SIZE ; j += 1
loop .inner_loop
pop rcx ; // restore inner loop counter
pop rax ; // restore a[i]
cmp rsi, rbx ; // swap if minimum found
jz .no_min ; if (i != min_i)
mov rdi, [rbx] ; temp = a[min]
mov [rbx], rax ; a[min] = a[i]
mov [rsi], rdi ; a[i] = temp
.no_min:
add rsi, I64_SIZE ; i += 1
jmp .outer_loop ; } // end outer loop
.end:
ret