> For the complete documentation index, see [llms.txt](https://doongu.gitbook.io/pk_select/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doongu.gitbook.io/pk_select/project-development/untitled/ui/secondpage/table/undefined.md).

# 데이터 정렬

login 성공 후 응답 받은 json 데이터를 강의, 과제, 시험 별로 분류를 한 뒤, 마감 기한이 임박한 과목부터 표시하고 과목 안에서도 마감기한이 임박한 항목 순으로 정렬한다.

```javascript
let lms_data_json = new Array(json['lms_data'].length)

                for (let i = 0; i < json['lms_data'].length; i++) {
                    lms_data_json[i] = json['lms_data'][i]
                }
                //강의, 과제, 시험 별로 분류
                let subject = new Array(3)

                for (let s = 0; s < 3; s++) {
                    subject[s] = new Array(0)
                }

                for (let i = 0; i < lms_data_json.length; i++) {
                    if (lms_data_json[i]['class'] == '수업') {
                        subject[0].push(lms_data_json[i])
                    } else if (lms_data_json[i]['class'] == '과제') {
                        subject[1].push(lms_data_json[i])
                    } else {
                        subject[2].push(lms_data_json[i])
                    }
                }


                //subject[]를 날짜 순으로 정렬
                for (let s = 0; s < 3; s++) {
                    subject[s] = subject[s].sort((a, b) => {
                        if (a['date_deadline'] > b['date_deadline']) {
                            return 1;
                        } else if (a['date_deadline'] < b['date_deadline']) {
                            return -1;
                        }
                    })
                }

                //list_sequence[]에 강의,과제,시험 별로 존재하는 과목을 1번만 날짜 순서대로 추출
                let list_sequence = new Array(3);
                for (let s = 0; s < 3; s++) {
                    list_sequence[s] = new Array(0);
                    list_sequence[s] = subject[s].map(function (Subject_name) {
                        // arr : subject_name만 추출
                        return Subject_name['subject_name'];
                    }).filter(function (Subject_name, index, arr) {
                        // arr.indexOf(Subject_name): arr에 속하는 Subject_name의 인덱스가 
                        // 지금 계산 중인 엔덱스와 같으면 반환
                        return arr.indexOf(Subject_name) === index;
                    });
                }

                // list_sequence[]에 쌓인 과목 순으로 subject[]추출해서 answer[]에 push
                let list_sequence_deque = new Array(3)
                let len_deque = new Array(3)
                let answer = new Array(3)
                for (let s = 0; s < 3; s++) {
                    list_sequence_deque[s] = new Deque
                    for (let i = 0; i < list_sequence[s].length; i++) {
                        list_sequence_deque[s].push_back(list_sequence[s][i])
                    }
                    len_deque[s] = list_sequence_deque[s]['arr'].length
                    answer[s] = new Array()

                    for (let i = 0; i < len_deque[s]; i++) {
                        let current_subject = list_sequence_deque[s].pop_front()
                        for (let j = 0; j < subject[s].length; j++) {
                            if (current_subject == subject[s][j]['subject_name']) {
                                answer[s].push(subject[s][j])
                            } else {
                                continue;
                            }
                        }
                    }
                }
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doongu.gitbook.io/pk_select/project-development/untitled/ui/secondpage/table/undefined.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
