GRay[s] так называется мой проект, и пока всё идёт в мат. прогрессии.
Но возникают иногда проблемы.
Проблема такая:
Мне надо отсортировать поля в нутри типа по убыванию.
Вот где то здесь нашел код (пример), но ничё непонял.
;================================================= ========
MinStr$ = ""
MinInt% = -(2^31) ; This is $80000000
MinFlt# = -2 * ( 2^127 - 2^103 ) ; Could also use -(2^12
= -Infinity.
; Example uses integers. If this changes then change temp to match.
Type Item
Field Index% ; integer for this example
End Type
t.Item = New Item
t\Index = MinInt ; sentinel, the smallest integer
For n = 1 To 15
t = New Item
t\Index = Rand(9)
Next ; the actual data
ShowData
InsertionSortSentinel
ShowData
Function InsertionSortSentinel()
Local sItem.Item, NextItem.Item, p.Item
Local temp% ; must be same type as the sort field.
NextItem=After First Item
Repeat
If NextItem = Null Then Return
sItem = NextItem
NextItem=After NextItem
temp=Item\Index
p = Before Item
While temp < p\Index
p = Before p
Wend
Insert Item After p
Forever
End Function
Function ShowData( )
For a.Item = Each Item
Write a\Index+" "
Next
Print : Print
End Function
;================================================= ========
Дело в том что функция сортирует не так как мне надо, а наоборот, по возрастанию.
Пожалуйста обьясните мне как это работает, и если можно подскажите что сделать (ну это так, если недоганю
)