Aug 24, 2016

Container sort2 [컨테이너값 정렬 시키기2]

container               _containerValue;
    container               _containerValueEach;
    container               _containerSort;
   
    container               _TempContainer1;
    container               _TempContainer2;
   
    int                     _i;
    int                     _j;
    _containerValueEach = [40,"TEST1"];
    _containerValue += [_containerValueEach];
    _containerValueEach = [70,"TEST2"];
    _containerValue += [_containerValueEach];
    _containerValueEach = [50,"TEST3"];
    _containerValue += [_containerValueEach];
    _containerValueEach = [30,"TEST4"];
    _containerValue += [_containerValueEach];
    _containerValueEach = [90,"TEST5"];
    _containerValue += [_containerValueEach];
    _containerSort = _containerValue;
    for (_i = 1; _i <= conlen(_containerSort); _i++)
    {
        for (_j = _i + 1; _j <= conlen(_containerSort); _j++)
        {
            _TempContainer1 = conpeek(_containerSort, _i);
            _TempContainer2 = conpeek(_containerSort, _j);
            if (conpeek(_TempContainer1,1) < conpeek(_TempContainer2,1))
            {
                _containerSort = condel(_containerSort, _j, 1);
                _containerSort = conins(_containerSort, _j, _TempContainer1);
                _containerSort = condel(_containerSort, _i, 1);
                _containerSort = conins(_containerSort, _i, _TempContainer2);
            }
        }
    }
    conview(_containerSort);

No comments:

Post a Comment