@marvin
Unfortunately, you havent really posted any code that will run...just a description of what your are trying to do. Its near impossible to find the bug in your code without any code to work with im afraid.
It sounds as though you are not sorting correctly or are inserting new items into a position that are not sorted...it could be something else (indexing, a simple mistype etc....).
Qugurun has given you a really great example of it sorting and searching correctly. Awesome reply that^^^

Here's another really simple example where you can insert or remove items and the array remains sorted and the searches work fine:
// Project: ArraySorting
// Created: 2019-12-10
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "ArraySorting" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
type BMtype
_nr as integer
x1 as integer
x2 as integer
//....etc...
endtype
bm as BMtype[10]
bm[0]._nr = 1
bm[1]._nr = 5
bm[2]._nr = 4
bm[3]._nr = 3
bm[4]._nr = 2
bm[5]._nr = 1
bm[6]._nr = 5
bm[7]._nr = 4
bm[8]._nr = 3
bm[9]._nr = 2
bm[10]._nr = 1
bm.sort()
global tx as string
do
// print the array
tx = ""
for i = 0 to bm.length
tx = tx+ str(bm[i]._nr)+", "
next i
print("Array contents: " + tx)
print("There are: " + str(bm.length+1) + " items in the array")
// press i to insert another element
print("Press i key to insert another item")
if GetRawKeyPressed(73)
newitem as BMtype
newitem._nr = random(1,9)
bm.insertsorted(newitem)
endif
// press d to delete a random element
print("Press d key to delete an element")
if GetRawKeyPressed(68)
if bm.length>=0 then bm.remove(random(0,bm.length))
endif
// do a search for the first number "3"
ind = bm.find(3)
print("The first number 3 is at index: " +str(ind))
// do a search for the first number "5"
ind = bm.find(5)
print("The first number 5 is at index: " +str(ind))
// Check if we want to exit
print("press esc to exit")
if getrawkeypressed(27) then end
Sync()
loop
my guess is that your doing something wrong but its difficult to say what without an example that is failing.