# 配列ソートに関して

**URL:** <https://forum.uipath.com/t/topic/69845>\
**Category:** フォーラム\
**Tags:** activities\
**Created:** [October 11, 2018, 4:18am UTC](https://forum.uipath.com/t/topic/69845 "2018-10-11T04:18:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![matrix99999](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/matrix99999/32/121413_2.png) [@matrix99999](https://forum.uipath.com/u/matrix99999)\
**Post date:** [October 11, 2018, 4:18am UTC](https://forum.uipath.com/t/topic/69845/1 "2018-10-11T04:18:13Z")

</div>

フォルダ内のファイルを配列に格納して、配列データソートを考えています。

処理対象ファイルの決定 (Assign)   
WK\_targetPdflFiles= IO.Directory.GetFiles(path\_name + wk\_pdf, “\*.pdf”)

配列のソート(Assign)  
targetPdflFiles = array.sort(WK\_targetPdflFiles)

変数：WK\_targetPdflFilesとtargetPdflFilesはstringと設定しています。

.netの書籍・サイトを確認しましたが文法的にはあっているみたいですが  
array.sort(WK\_targetPdflFiles)の設定でエラーが出ます。

ご教示いただければと思います。

---

<div class="post-metadata">

**Author:** ![SUZUKI\_Yasuharu](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@SUZUKI\_Yasuharu](https://forum.uipath.com/u/SUZUKI_Yasuharu)\
**Post date:** [October 11, 2018, 5:45am UTC](https://forum.uipath.com/t/topic/69845/2 "2018-10-11T05:45:11Z")

</div>

Array.Sortは戻り値を返さないので  
targetPdflFiles = array.sort(WK\_targetPdflFiles)  
↑これを↓こうで大丈夫じゃないでしょうか  
Array.Sort(WK\_targetPdflFiles)

---

<div class="post-metadata">

**Author:** ![Honoka](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/honoka/32/19907_2.png) [@Honoka](https://forum.uipath.com/u/Honoka)\
**Post date:** [October 11, 2018, 6:05am UTC](https://forum.uipath.com/t/topic/69845/3 "2018-10-11T06:05:25Z")

</div>

LINQを使って

```
 WK_targetPdflFiles.OrderBy(Function(s) s).ToArray()

```

だと、ソート後の値をAssignできます。
