---
title: "Why do We need to Sort Table Prior to COBOL SEARCH ALL"
description: "Why table should be sorted for SEARCH ALL . The simple and informative post highly helpful to all COBOL developers."
url: https://srinimf.com/2016/11/08/why-sorting-is-needed-for-search-all/
date: 2016-11-08
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2018/05/norway-mountain-sky-blue-e1535287763653.jpg?fit=500%2C333&ssl=1
categories: ["COBOL"]
tags: ["Why sorting need in COBOL Search all"]
type: post
lang: en
---

# Why do We need to Sort Table Prior to COBOL SEARCH ALL

## COBOL [Search All](https://srinimf.com/2015/10/02/cobol-search-and-search-all-differences/)

Search is binary, so the table must be [in sort](https://srinimf.com/2015/05/12/jcl-include-omit-examples/)ed condition. As many as twelve keys you can give in **SEARCH ALL.** The total size of all the keys should not exceed 256 bytes.

![COBOL SEARCH ALL: Here's Why Table Sorting Needed](https://i0.wp.com/srinimf.com/wp-content/uploads/2016/11/pexels-photo-7693914.jpeg?resize=914%2C1300&ssl=1)*Photo by Marta Dzedyshko on [Pexels.com](https://www.pexels.com/photo/bouquet-of-peonies-placed-in-glass-vase-on-windowsill-7693914/)*

According to computerhope.com – A binary search, also known as a **half-interval search, is an algorithm used i[n computer](https://srinimf.com/2014/03/23/get-mobile-n-computer-parts/) science [to locate](https://srinimf.com/2014/09/04/db2-functions-posstr-and-locate/) a specified value ( key) within an array**. For the search to be binary, the array must be sorted in either ascending or descending order.

**Also read**

- [5 COBOL Frequently Asked Interview Questions](https://srinimf.com/2014/08/07/5-best-cobol-questions-and-solutions/)DateAugust 7, 2014
- [Best Example for COBOL SEARCH and WHEN Condition](https://srinimf.com/2016/01/06/best-example-for-cobol-search-and-when-condition/)DateJanuary 6, 2016
- [Search Vs Search all in COBOL: Top Differences](https://srinimf.com/2015/10/02/cobol-search-and-search-all-differences/)DateOctober 2, 2015

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2016%2F11%2F08%2Fwhy-sorting-is-needed-for-search-all%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2018%2F05%2Fnorway-mountain-sky-blue-e1535287763653.jpg%3Ffit%3D500%252C333%26ssl%3D1&description=Why%20do%20We%20need%20to%20Sort%20Table%20Prior%20to%20COBOL%20SEARCH%20ALL)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2016/11/08/why-sorting-is-needed-for-search-all/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2016/11/08/why-sorting-is-needed-for-search-all/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2016/11/08/why-sorting-is-needed-for-search-all/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2016/11/08/why-sorting-is-needed-for-search-all/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20Why%20do%20We%20need%20to%20Sort%20Table%20Prior%20to%20COBOL%20SEARCH%20ALL&body=https%3A%2F%2Fsrinimf.com%2F2016%2F11%2F08%2Fwhy-sorting-is-needed-for-search-all%2F&share=email)
-

### Like this:

Like Loading…
