Files
mql5-skills/skills/mql5/references/docs/34-standardlibrary/1736-standardlibrary-datastructures-carraystring-carraystringinsertsort.md
T

53 lines
934 B
Markdown
Raw Normal View History

2026-06-23 21:47:51 +08:00
# InsertSort
Inserts an element in a sorted array.
```
bool  InsertSort(
   string  element      // element to insert
   )
```
Parameters
element
[in] Value of the element to be inserted into a sorted array
Return Value
true - successful, false - cannot insert the element.
Example:
```
//--- example for CArrayString::InsertSort(string)
#include <Arrays\ArrayString.mqh>
//---
void OnStart()
  {
   CArrayString *array=new CArrayString;
   //---
   if(array==NULL)
     {
      printf("Object create error");
      return;
     }
   //--- add arrays elements
   //--- . . .
   //--- sort array
   array.Sort();
   //--- insert element
   if(!array.InsertSort("ABC"))
     {
      printf("Insert error");
      delete array;
      return;
     }
   //--- delete array
   delete array;
  }
```