개발 Q&A

제목 배열 정렬 답변 부탁드립니다.ㅠㅠ
글쓴이 초보프로그래머 작성시각 2015/06/03 20:37:39
댓글 : 1 추천 : 0 스크랩 : 0 조회수 : 11961   RSS
일단 디비에 있는 값을 1 2 3 4 5 6 7 8 9 10 11 12

이런식으로 가지고 올라고 하는데요.

문자열이에요...

인덱스는 없습니다.

1~9까지는 잘 소팅 되지만

만약 10 단위가 넘어가게 된다면

1,10,11,12,2,3,4,5,6,7,8,9 이런식으로 됩니다..

익스플로드로 잘라서 막 포문돌아서 해야될까요?ㅠㅠ

아니면 mysql 에 LPAD 자연정렬이 있는데 이거 쓰는게 더 낫겠죠?

팀좀 주세요 ㅠㅠ

데이터는
 
Array
(
    [0] => stdClass Object
        (
            [meta_key] => shortcut_1
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:1:"1";s:13:"shortcut_link";s:1:"/";}
        )

    [1] => stdClass Object
        (
            [meta_key] => shortcut_10
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:2:"10";s:13:"shortcut_link";s:1:"/";}
        )

    [2] => stdClass Object
        (
            [meta_key] => shortcut_10_file_id
            [meta_value] => 
        )

    [3] => stdClass Object
        (
            [meta_key] => shortcut_11
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:2:"11";s:13:"shortcut_link";s:1:"/";}
        )

    [4] => stdClass Object
        (
            [meta_key] => shortcut_11_file_id
            [meta_value] => 
        )

    [5] => stdClass Object
        (
            [meta_key] => shortcut_12
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:2:"12";s:13:"shortcut_link";s:0:"";}
        )

    [6] => stdClass Object
        (
            [meta_key] => shortcut_12_file_id
            [meta_value] => 
        )

    [7] => stdClass Object
        (
            [meta_key] => shortcut_13
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:2:"13";s:13:"shortcut_link";s:0:"";}
        )

    [8] => stdClass Object
        (
            [meta_key] => shortcut_13_file_id
            [meta_value] => 
        )

    [9] => stdClass Object
        (
            [meta_key] => shortcut_14
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:2:"14";s:13:"shortcut_link";s:0:"";}
        )

    [10] => stdClass Object
        (
            [meta_key] => shortcut_14_file_id
            [meta_value] => 
        )

    [11] => stdClass Object
        (
            [meta_key] => shortcut_15
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:2:"15";s:13:"shortcut_link";s:0:"";}
        )

    [12] => stdClass Object
        (
            [meta_key] => shortcut_15_file_id
            [meta_value] => 
        )

    [13] => stdClass Object
        (
            [meta_key] => shortcut_16
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:2:"16";s:13:"shortcut_link";s:0:"";}
        )

    [14] => stdClass Object
        (
            [meta_key] => shortcut_16_file_id
            [meta_value] => 
        )

    [15] => stdClass Object
        (
            [meta_key] => shortcut_1_file_id
            [meta_value] => 
        )

    [16] => stdClass Object
        (
            [meta_key] => shortcut_2
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:1:"2";s:13:"shortcut_link";s:1:"/";}
        )

    [17] => stdClass Object
        (
            [meta_key] => shortcut_2_file_id
            [meta_value] => 
        )

    [18] => stdClass Object
        (
            [meta_key] => shortcut_3
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:1:"3";s:13:"shortcut_link";s:1:"/";}
        )

    [19] => stdClass Object
        (
            [meta_key] => shortcut_3_file_id
            [meta_value] => 
        )

    [20] => stdClass Object
        (
            [meta_key] => shortcut_4
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:1:"4";s:13:"shortcut_link";s:1:"/";}
        )

    [21] => stdClass Object
        (
            [meta_key] => shortcut_4_file_id
            [meta_value] => 
        )

    [22] => stdClass Object
        (
            [meta_key] => shortcut_5
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:1:"5";s:13:"shortcut_link";s:1:"/";}
        )

    [23] => stdClass Object
        (
            [meta_key] => shortcut_5_file_id
            [meta_value] => 
        )

    [24] => stdClass Object
        (
            [meta_key] => shortcut_6
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:1:"6";s:13:"shortcut_link";s:1:"/";}
        )

    [25] => stdClass Object
        (
            [meta_key] => shortcut_6_file_id
            [meta_value] => 
        )

    [26] => stdClass Object
        (
            [meta_key] => shortcut_7
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:1:"7";s:13:"shortcut_link";s:1:"/";}
        )

    [27] => stdClass Object
        (
            [meta_key] => shortcut_7_file_id
            [meta_value] => 
        )

    [28] => stdClass Object
        (
            [meta_key] => shortcut_8
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:1:"8";s:13:"shortcut_link";s:1:"/";}
        )

    [29] => stdClass Object
        (
            [meta_key] => shortcut_8_file_id
            [meta_value] => 
        )

    [30] => stdClass Object
        (
            [meta_key] => shortcut_9
            [meta_value] => a:3:{s:17:"shortcut_subtitle";s:0:"";s:14:"shortcut_title";s:1:"9";s:13:"shortcut_link";s:1:"/";}
        )

    [31] => stdClass Object
        (
            [meta_key] => shortcut_9_file_id
            [meta_value] => 
        )

)
이런 식 입니다..ㅠㅠ
 다음글 이메일 보내는 속도가 너무 느린데요. (5)
 이전글 여러 줄의 텍스트가 줄바꿈될 때 줄바꿈시 위치찾기 (1)

댓글

한대승(불의회상) / 2015/06/04 09:14:31 / 추천 0
uasort()를 사용하세요.